15

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.

jcubic
  • 61,973
  • 54
  • 229
  • 402
Mourad Idrissi
  • 3,455
  • 5
  • 17
  • 29

10 Answers10

20

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.

MThi
  • 323
  • 2
  • 5
20

In Visual Studio code go to File -> Preferences -> Settings and check Experimental Decorators

enter image description here

R15
  • 13,982
  • 14
  • 97
  • 173
16

Go to File/preference/user settings in vscode, put this code

{
  "typescript.tsdk": "node_modules/typescript/lib"
}
6

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"
    ]
}
Jared
  • 2,006
  • 4
  • 23
  • 43
2

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
sumitjainjr
  • 741
  • 1
  • 8
  • 28
1

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

1

In VS Code, open settings.json and add this line:

"javascript.implicitProjectConfig.experimentalDecorators": true

Edgar Quintero
  • 4,223
  • 2
  • 34
  • 37
0

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.

michal.jakubeczy
  • 8,221
  • 1
  • 59
  • 63
0

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

Ash
  • 35
  • 6
-1

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.

Abhinandan
  • 429
  • 8
  • 13