我最近用Visual Studio Code开发Angular项目时,打开app.component.ts, 就遇到如下的警告消息:
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.ts(1219)
![](https://img.laitimes.com/img/__Qf2AjLwojIjJCLyojI0JCLicmbw5CO0U2N5EmMmZDZyMGZhBTO5gjN0QWOiRmYwgTY5czYj9CX5d2bs92Yl1iclB3bsVmdlR2LcNWaw9CXt92Yu4GZjlGbh5yYjV3Lc9CX6MHc0RHaiojIsJye.png)
解决办法:
在项目根目录的tsconfig.json文件里,加入如下设置:
/*
This is a "Solution Style" tsconfig.json file, and is used by editors and TypeScript’s language server to improve development experience.
It is not intended to be used to perform a compilation.
To learn more about this file see: https://angular.io/config/solution-tsconfig.
*/
{
"files": [],
"references": [
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.spec.json"
}
],
"compilerOptions": {
"experimentalDecorators":true,
"emitDecoratorMetadata": true
}
}
关掉所有文件,进入Angular项目根目录,code .重启Visual Studio Code,错误消失: