ts decorator(装饰器)使用报错问题
简单的写一个装饰器
报错信息:
Experimental support for decorators is a feature that is subject to change in a future release. Set the ‘experimentalDecorators’ option in your ‘tsconfig’ or ‘jsconfig’ to remove this warning.
1.修改tsconfig.js文件
另外 tsconfig.js 快速创建方式
tsc --init
修改
/* Experimental Options */
// "experimentalDecorators": true,
// "emitDecoratorMetadata": true,
为
/* Experimental Options */
"experimentalDecorators": true,
// "emitDecoratorMetadata": true,
2.file->preferences->settings
搜索 Experimental Decorators
3.试了前面两种还不行 编译时加上–experimentalDecorators
tsc demo.ts --experimentalDecorators
4.浏览器报错
用node执行编译后的js代码
node demo.js