TypeScript Compiler Options

emitDecoratorMetadata — TypeScript compiler option

Emits selected design-time metadata for decorated declarations under the legacy model. Requires experimentalDecorators. A compatible runtime reflection implementation is needed to store and read metadata; it does not preserve arbitrary generic, union or structural types. Default in 5.8.3: false. Create the labeled files in an isolated project and run tsc -p tsconfig.json. Expected stdout: '4'. Expected emitted files: dist/main.js. Local project fixture, not a single-file editor.

Formal Syntax & Structure

typescript syntaxtypescript
{  "compilerOptions": {    "emitDecoratorMetadata": true  }}

Parameters & Attributes

NameTypeDescription
emitDecoratorMetadatabooleanSet 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,    "emitDecoratorMetadata": true  },  "files": [    "main.ts"  ]}// File: main.tsfunction tag(target: object, key: string | symbol) {}class Model { @tag count: number = 4; }console.log(new Model().count);
TypeScript Reference