TypeScript Compiler Options
experimentalDecorators — TypeScript compiler option
Enables legacy TypeScript decorators including parameter decorators. Without this option, supported modern decorators use different signatures and initialization semantics. Do not interchange the models. Default in 5.8.3: false. Create the labeled files in an isolated project and run tsc -p tsconfig.json. Expected stdout: 'parameter 0\n3'. Expected emitted files: dist/main.js. Local project fixture, not a single-file editor.
Formal Syntax & Structure
typescript syntaxtypescript
{ "compilerOptions": { "experimentalDecorators": true }}Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| experimentalDecorators | boolean | Set in compilerOptions; default in 5.8.3: false. |
Working Example
Example Snippettypescript
// File: tsconfig.json (omit this label){ "compilerOptions": { "target": "ES2022", "module": "CommonJS", "strict": true, "types": [], "noEmitOnError": true, "outDir": "dist", "experimentalDecorators": true }, "files": [ "main.ts" ]}// File: main.tsfunction mark(target: object, key: string | symbol | undefined, index: number) { console.log("parameter", index); }class Service { run(@mark value: number) { return value; } }console.log(new Service().run(3));