What are Decorators in TypeScript ?
Last Updated :
22 Feb, 2024
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
}
}
Share your thoughts in the comments
Please Login to comment...