Visual Studio Code to allow decorator syntax

Posted in Uncategorized

Tweet This Share on Facebook Bookmark on Delicious Digg this Submit to Reddit

You might be getting this lint error …

Experimental support for decorators is a feature that is subject to change that is subject to change in a future release. Set the ‘experimentalDecorators’ option to remove this warning. ts(1219)

if you have eslint plugin installed in Visual Studio Code and are using React decorator syntax such as …

@inject("store") 
@observer
class Hello extends Component { ... }

The warning message gives us a clue as to how to let Visual Studio Code allow for this syntax. The “ts(1219)” code at the end of the warning refers to “TypeScript”.

Searching “typescript experimentalDecorators” may find the remedy, which is to create a tsconfig.json file at the root of the project. tsconfig.json is a config file for Typescript.

Add the following config in the tsconfig.json

{   
"compilerOptions": {
"experimentalDecorators": true
}
}

And restart Visual Studio.


Related Posts

Tags

Share This