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.

8 thoughts on “How to remove experimentalDecorators warning in VSCode

  1. Tadeas

    Thanks a tonne for this! Weird that you have to create a TypeScript config file to get rid of purely JS errors though…

    Reply
  2. Ivan

    You can also create a `jsconfig.json` with the almost the same content (you can leave `allowjs` out). At least people won’t assume they have to use typescript when opening this project. :)

    Reply
  3. Marcel

    Create the jsconfig.json in the .vscode folder of your project root level. I was confused having a ts-config when not using ts, too.

    Reply

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>