2
votes

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.

3

3 Answers

2
votes

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

enter image description here

0
votes

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.

0
votes

You will still get the error message if you click on any relevant declaration while Visual Studio Code has your project open in too narrow a scope, i.e. when VSC doesn't know your tsconfig.json file even exists, because it's not open in your folder view.