refactor: 迁移到TC39标准装饰器

- 将实验性装饰器重构为TC39 Stage 3标准装饰器
- 使用ClassMethodDecoratorContext和ClassDecoratorContext
- 采用addInitializer方法进行装饰器初始化
- 移除reflect-metadata依赖,使用WeakMap存储元数据
- 更新TypeScript配置为ES2021目标版本
- 简化tsconfig.json配置,移除useDefineForClassFields显式设置
- 创建TC39标准装饰器使用指南文档

技术优势:
- 符合ECMAScript官方标准提案
- 零外部依赖,性能更优
- 完整TypeScript类型支持
- 未来原生浏览器兼容

Breaking Changes: 无,装饰器语法保持兼容
This commit is contained in:
2025-09-02 06:49:32 +08:00
parent 63c1e4df63
commit d178df54da
6 changed files with 168 additions and 60 deletions

8
pnpm-lock.yaml generated
View File

@@ -23,9 +23,6 @@ importers:
koa:
specifier: ^3.0.1
version: 3.0.1
reflect-metadata:
specifier: ^0.1.13
version: 0.1.14
devDependencies:
'@tsconfig/node-ts':
specifier: ^23.6.1
@@ -1463,9 +1460,6 @@ packages:
reduce-configs@1.1.1:
resolution: {integrity: sha512-EYtsVGAQarE8daT54cnaY1PIknF2VB78ug6Zre2rs36EsJfC40EG6hmTU2A2P1ZuXnKAt2KI0fzOGHcX7wzdPw==}
reflect-metadata@0.1.14:
resolution: {integrity: sha512-ZhYeb6nRaXCfhnndflDK8qI6ZQ/YcWZCISRAWICW9XYqMUwjZM9Z0DveWX/ABN01oxSHwVxKQmxeYZSsm0jh5A==}
resize-observer-polyfill@1.5.1:
resolution: {integrity: sha512-LwZrotdHOo12nQuZlHEmtuXdqGoOD0OhaxopaNFxWzInpEgaLWoVuAMbTzixuosCx2nEG58ngzW3vxdWoxIgdg==}
@@ -2936,8 +2930,6 @@ snapshots:
reduce-configs@1.1.1: {}
reflect-metadata@0.1.14: {}
resize-observer-polyfill@1.5.1: {}
resolve-from@4.0.0: {}