Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode: Is it possible to suppress experimental decorator warnings

In VSCode, I get the error:

"Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning."

I can add the --experimentalDecorators flag to my tasks.json file to remove this error on build, but I can't seem to remove it from my intellisense or error list when I load VSCode.

Is there a way to do this?

like image 484
bingles Avatar asked Jul 31 '15 03:07

bingles


People also ask

How do I get rid of Experimentaldecorator warning in Visual Studio?

Go to File -> Preferences -> Settings. 2. Search "experimentalDecorators" 3. Check Enable/disable experimentalDecorators 4.

How do I get rid of warnings in Vscode?

enable": false //... } in our settings. json file to disable TypeScript and JavaScript warnings by setting typescript. validate.


2 Answers

I was having this same error. I added the following tsconfig.json file to my project root, restarted VSCode and it finally went away:

{     "compilerOptions": {         "emitDecoratorMetadata": true,         "experimentalDecorators": true,         "module": "amd",         "target": "ES6"      } } 

UPDATE:

I've noticed that sometimes VS Code will not suppress this warning until you add a "files" array in your tsconfig.json, even an empty one will work. For me this has worked every single time now, if the message does not disappear, try the following:

{     "compilerOptions": {         ...      },     "files": [],     "exclude": [         "node_modules"     ] } 

Perhaps this will explain why everyone has mixed results?

like image 78
Felipe Avatar answered Oct 03 '22 18:10

Felipe


VSC is by default looking at its own TS library and definition. If you're using a different version (which is very likely) you should point VSC to look for that versions definition.

In my settings.json file, i have the following set up:

// Place your settings in this file to overwrite default and user settings. {     "typescript.tsdk": "node_modules\\typescript\\lib"  } 

I believe you can set this for either your User Settings or your Workspace Settings. So you can do a one time configuration in your User Settings or just for one project/workspace. This works if you have your typescript installed locally in the specified folder - which i believe is the default nodes module folder.

To edit your settings go to File/Preferences/User Setting or File/Preference/Workspace Settings.

UPDATE: Visual Studio Code just released a new version with better support for different versions of typescript. Check it out here: https://code.visualstudio.com/updates#_languages

like image 31
Per Hornshøj-Schierbeck Avatar answered Oct 03 '22 18:10

Per Hornshøj-Schierbeck