VSCode and experimentalDecorators warning

How to remove experimentalDecorators warning in VSCode

Are you getting this annoying experimentalDecorators warning in VSCode? I have spent a few hours before finding a solution, I hope this will save you your valuable time.

The Issue

VSCode and experimentalDecorators warning

When I was setting up new React and Mobx project from scratch, I was getting the following warning in VSCode.

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

Every-time I have introduced MOBX @observable decorator, VSCode didn’t like it and underlined the relevant React class.

Webpack compiled the project without any errors, but the warning in VSCode stayed.

Luckily there is a quick fix.

The solution

tsconfig.json for experimentalDecorators warning in VScode

Create tsconfig.json file in the root directory of your project and include the following options.

{
    "compilerOptions": {
        "experimentalDecorators": true,
        "allowJs": true
    }
}

Restart VSCode and you should not see any experimentalDecorators warnings anymore.

VSCode and experimentalDecorators warning

Hope it was useful and don’t forget to download the free React Cheat Sheet. Happy coding.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>