Reputation: 3785
I just cloned angular2-seed project from github and followed the steps, but i got this warning into VS code [ts] Experimental support for decorators is a feature that is subject to change in a future release. Set the 'Exxperimentaldecorators' option to remove this warning.
Upvotes: 15
Views: 33188
Reputation: 35
I solved a similar problem using a command like this
tsc .\app.ts --experimentalDecorators --target es6
where .\app.ts is the path of the file
Upvotes: 0
Reputation: 9489
I get this warning in VS Code on newly added classes. Project compiles without any errors. When I start to reference the newly added class via import
the warning diappears.
There is no need to change configuration in VS Code or Typescript in such case.
Upvotes: 0
Reputation: 17452
In Visual Studio code go to File -> Preferences -> Settings
and check Experimental Decorators
Upvotes: 20
Reputation: 4441
In VS Code, open settings.json
and add this line:
"javascript.implicitProjectConfig.experimentalDecorators": true
Upvotes: 1
Reputation: 11
In VS Code settings find "experimentalDecorators". This will list Extension->TypeScript with a property JavaScript-> Implicit Project Config -> Experimental Decorators enable this setting will resolve warrning
Upvotes: 1
Reputation: 771
Your tsconfig.json should be like this:
{
"compilerOptions": {
"experimentalDecorators": true
},
"files": [], //add a "files" array (in my case empty)
"exclude": [
"node_modules"
]
}
Alternatively you can add a line in VSCode preferences (user settings)
"javascript.implicitProjectConfig.experimentalDecorators": true
Upvotes: 2
Reputation: 323
I had that issue when using @Injectable() on a new service that I created. I had that warning from VS Code's typescript compiler.
The warning disappeared when I added that new service as a provider to the module where I intended to use it.
Hopefully this solves your issue.
Upvotes: 20
Reputation: 2096
In your tsconfig.json
file, add your project's path to the include
property like this:
"include": [
"app/**/*"
]
Or alternatively you can add individual files to the files
property. Here is what my tsconfig.json
looks like as an example (for an Angular2 app):
{
"compileOnSave": false,
"buildOnSave": false,
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"noEmitHelpers": true,
"sourceMap": true,
"types": [
"node"
],
"typeRoots": [
"../node_modules/@types"
],
"lib": [
"es2015",
"dom"
]
},
"files": [
"app/main.ts",
"app/app.module.ts"
],
"include": [
"app/**/*.ts"
],
"exclude": [
"node_modules",
"dist",
"build",
"app/main.aot.ts"
]
}
Upvotes: 6
Reputation: 187
Go to File/preference/user settings in vscode, put this code
{
"typescript.tsdk": "node_modules/typescript/lib"
}
Upvotes: 16
Reputation: 439
It is due to the use of older version of typescript. You must upgrade your typescript version to remove this message.
npm install -g typescript@latest
Also you need to upgrade your npm to latest version as well.
Upvotes: -1