Search code examples
javascriptangulartypescriptreflect-metadata

Where do I find the metadataKey values used in reflect-metadata


I'm using typescript and Angular (2.4.7)

reflect-metadata refers to magical strings, where do I find what these are, where they are defined? For example "design:type"

function Type(type) { return Reflect.metadata("design:type", type); }
function ParamTypes(...types) { return Reflect.metadata("design:paramtypes", types); }
function ReturnType(type) { return Reflect.metadata("design:returntype", type); }

Solution

  • It is from typescript compiler with enabled emitDecoratorMetadata option

    https://github.com/Microsoft/TypeScript/blob/ef25b25c1fb64602f99a6278f24d42c1b6d53d90/src/compiler/transformers/ts.ts#L1360-L1376

    https://github.com/Microsoft/TypeScript/blob/ef25b25c1fb64602f99a6278f24d42c1b6d53d90/src/compiler/transformers/ts.ts#L1498-L1528

    enter image description here