Open In App

What are Decorators in TypeScript ?

Last Updated : 22 Feb, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

Decorators in TypeScript are the language-specific feature used to modify and transform the classes and their members at the time of their declarations. Decorators are the simple functions defined using the @ symbol before their names. Decorators can be applied to the declaration of the classes, methods, properties, parameters, etc. You can use the below methods to enable the TypeScript decorators in your current project.

tsc --target ES5 --experimentalDecorators
  • Manually enabling the decorators: You can also enable the decorators in your current project by updating your tsconfig.json file with the below code.
{
'compilerOptions': {
'target': ES5,
'experimentalDecorators': true
}
}

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads