简体   繁体   中英

ExperimentalDecorators Warning

I had an application with Angular 4, and I tried test with jasmine and Karma. But this error it occurred.

Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning.

this is my tsconfig file

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/",
    "baseUrl": "./",
    "sourceMap": true,
    "declaration": true,
    "module": "commonjs",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es6",
      "dom"
    ]
  },
  "angularCompilerOptions": {
    "genDir": "aot",
    "strictMetadataEmit": true
  }
}

I just edited settings.json of VScode and put this code

"typescript.tsdk": "node_modules\\typescript\\lib"

but didn't work.

If you don't want to create the file jsconfig.json or tsconfig.json you can just enable experimentarDecorators for all your projects in Visual Studio Code:

  1. File > Preference > Settings
  2. Search: experimentalDecorators
  3. Enable the checkbox

在此处输入图片说明

I just experienced the same issue. I followed these steps to solve the problem:

1- Add this line to my Visual Studio Code settings: "javascript.implicitProjectConfig.experimentalDecorators": true,

2- Add the option "experimentalDecorators": true, to the compilerOptions of the tsconfig.json file of the project. (As you already have in your code)

And my problem was solved.

如果您在 Visual Studio Code 将您的项目打开的范围太窄时单击任何相关声明,您仍然会收到错误消息,即当 VSC 不知道您的 tsconfig.json 文件甚至存在时,因为它没有在您的文件夹中打开看法。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM