Fix - Experimental support for decorators is a feature that is subject to change in a future release

avatar

Borislav Hadzhiev

Thu Mar 24 20222 min read

banner

Photo by Jonatan Pie

Fix - Experimental support for decorators is a feature that is subject to change in a future release #

To solve the error "Experimental support for decorators is a feature that is subject to change in a future release", make sure to set the experimentalDecorators to true in your tsconfig.json file and restart your IDE and development server if necessary.

experimental support is feature subject to change

Here is an example of how the error occurs.

index.ts
// ⛔️ Error: Experimental support for decorators is a feature // that is subject to change in a future release. // Set the 'experimentalDecorators' option in your 'tsconfig' or 'jsconfig' to remove this warning.ts(1219) @sealed class BugReport { type = 'report'; title: string; constructor(t: string) { this.title = t; } } function sealed(constructor: any) { Object.seal(constructor); Object.seal(constructor.prototype); }
The first thing you need to do is check if you have the experimentalDecorators enabled in your tsconfig.json file.

Note that this may also be your tsconfig.app.json file if using Angular, or whichever config file is used in your build process.

tsconfig.json
{ "compilerOptions": { "target": "es6", "rootDir": "src", "outDir": "build", "experimentalDecorators": true, // 👈️ must be enabled "emitDecoratorMetadata": true, }, "include": ["src/**/*"], "exclude": ["node_modules"] }

The experimentalDecorators setting enables experimental support for decorators.

If you use the include or files options, make sure the file you are using decorators in is included in your project and is being tracked by TypeScript.

If your project uses the exclude option, make sure your exclude array does not exclude the file in which you're using decorators.

The exclude option changes what the include option finds, effectively filtering out some folders or files from compilation.

If TypeScript can't find the file in which you are using decorators, you will get the error even after enabling experimentalDecorators.

Restart your IDE and development server after making the changes.

VSCode often glitches and needs a reboot even after you have set the experimentalDecorators option to true in your tsconfig.json file.

If you are getting the error in VSCode, you can use your editors settings to enable experimental decorators.

To solve the "Experimental support for decorators is a feature that is subject to change" in VSCode:

  1. Click on CTRL + , to open your editor's settings.
  2. In the search bar type: implicitProjectConfig.experimental
  3. Check the checkbox of the Experimental Decorators setting.

vscode enable experimental decorators

  1. Restart your IDE.
If none of the suggestions work, your code editor might be running an older version of TypeScript that doesn't support decorators.

If you use VSCode, you can press CTRL + Shift + P to open the command palette and type in typescript version and click on TypeScript: Select TypeScript version and then click Use Workspace version.

If you don't have TypeScript installed locally in your project, open your terminal in your project's root directory and install it.

shell
npm install -D typescript@latest

Now re-run the steps to be sure your code editor uses the right TypeScript version.

Use the search field on my Home Page to filter through my more than 1,000 articles.