且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何处理Angular项目在Visual Studio Code打开报关于@Decorators的警告信息

更新时间:2022-09-09 16:38:58

我最近用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)

如何处理Angular项目在Visual Studio Code打开报关于@Decorators的警告信息

解决办法:

在项目根目录的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项目在Visual Studio Code打开报关于@Decorators的警告信息

关掉所有文件,进入Angular项目根目录,code .重启Visual Studio Code,错误消失:如何处理Angular项目在Visual Studio Code打开报关于@Decorators的警告信息