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.

Updated Solution June 2020

In VSCode go to preferences -> settings, you will see an option to enable/disable experimentalDecorators. Check it and save the settings file. Done

Old 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.

48 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
    1. zad

      Didn’t work for me either. The following worked for me though: add the following line to your vscode User settings:

      “javascript.implicitProjectConfig.experimentalDecorators”: true

      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
  4. Dan Moran

    I’ve been trying to figure this out all day, working on a TypeScript project. I already had the `”experimentalDecorators”: true` entry, but that was not cutting it. The allowJs flag seems to be what did it for me. Thanks!

    Reply
  5. Michael Thornberry

    I’ve been trying to get rid of this for months and nothing seemed to work. I put the “compilerOptions” in just about every config file I could find and nothing changed. What finally did it for me was to put the following in .vscode\settings.json:

    {
    “javascript.implicitProjectConfig.experimentalDecorators”: true
    }

    Reply
    1. Lakshman Pilaka

      this worked for me.
      {
      “javascript.implicitProjectConfig.experimentalDecorators”: true
      }

      Reply
    2. Onno de Jong

      I had the same issue. Thanks to your comment, I managed to fix it quickly. I can’t stand errors and warnings in my projects.

      Reply
  6. Bhargavi Dudharejiya

    Neither of them worked for me 🙁 I tried the tsconfig.json and settings.json as well. Warning still appears “Experimental support for decorators is a feature that is subject to change in a future release. Set the ‘experimentalDecorators’ option to remove this warning.” ! 🙁
    Can anyone help ?

    Reply
  7. Grant Parkis

    I am in angular and vs code but I fixed it by going to:
    preferences -> settings
    in the search field type: javascript.implicit

    You will see an option to enable/disable experimentalDecorators for Javascript files…. check it and save the settings file

    All done.

    Reply
  8. Naomi Nosonovsky

    Grant Parkis, thanks for your solution, the original solution from that blog didn’t work for me, but yours did.

    Reply
    1. Naomi Nosonovsky

      I’m also using Angular. For the author of this blog – may be you’d like to move that directly into the blog itself (with attributes, of course), so other people looking for solution may find it quicker?

      Reply
  9. Agata

    Thank you so very very very much! I was using the older solution which is not working anymore and it was driving me crazy! You saved me!

    Reply

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.