问题:
在运行typescript:Handbook/Decrators文档示例时报错如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
index.ts:16:3 - error TS1241: Unable to resolve signature of method decorator when called as an expression. 16 @f() ~~~~ index.ts:17:3 - error TS1241: Unable to resolve signature of method decorator when called as an expression. 17 @g() ~~~~ index.ts:18:3 - error TS1219: 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. 18 method() {} ~~~~~~ Found 3 errors. |
注意:虽然报错,但是编译成功了!
解决:
可以通过监听ts文件的热更新,解决ts报错:
1 |
tsc myFileName.ts --target ES5 -w --experimentalDecorators |
参考: