In order to use or try Decorators in TypeScript, we need to enable it. Enabling Decorators can be done from tsconfig.json
file.
If the tsconfig.json
file has been created using tsc init
command, the file would have a default configuration. The file also has many configurations that are commented.
One such commented option is experimentalDecorators
. Uncomment the line that contains experimentalDecorators
json property and ensure that its value is true
.
Doing the above step will enable Decorators in TypeScript.