bensiu bensiu - 2 months ago 88
TypeScript Question

Experimental decorators warning in Visual Studio Code

I have


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


even my compilerOptions in tsconfig.json have settings:

"emitDecoratorMetadata": true,
"experimentalDecorators": true,


What is weird that some random classes that use decorators does not show that warning but rest in same project does.

What could cause such behavior of Visual Studio Code

Answer

Although VS Code is a great editor for TypeScript projects, it needs a kick every now and again. Often, without warning, certain files cause it to freak out and complain. Mostly the fix seems to be to save and close all open files, then open tsconfig.json. After that you should be able to re-open the offending file without error. If it doesn't work, lather, rinse, and repeat.

If your tsconfig.json specifies its source files using the files array, IntelliSense will only function correctly if the file in question is referenced such that VS Code can find it by traversing the input file tree.