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

avatar
Borislav Hadzhiev

Last updated: Feb 29, 2024
2 min

banner

# 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 code for this article is available on GitHub
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.

# Make sure the file is included in your project

If you use the include or files options, make sure the file you use 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.

The code for this article is available on GitHub

# Solve the error in Visual Studio Code

If you got the error in VSCode, you can use your editor's settings to enable experimental decorators.

To solve the error 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 rerun the steps to be sure your code editor uses the right TypeScript version.

The code for this article is available on GitHub

I've also written an article on how to check which version of TypeScript is installed.

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.