0Pricing
TypeScript Academy · Lesson

reflect-metadata and Design Types

Capture parameter and property types at runtime.

reflect-metadata and Design Types

Before standardized metadata existed, TypeScript could emit design-time type information at runtime via the reflect-metadata library plus the emitDecoratorMetadata compiler flag. This lesson covers that older but still widely used mechanism.

Enabling the Feature

Two things are required: turn on the compiler options and import the library once at the program entry point.

// tsconfig.json
// {
//   "compilerOptions": {
//     "experimentalDecorators": true,
//     "emitDecoratorMetadata": true
//   }
// }

import "reflect-metadata";

All lessons in this course

  1. Stage 3 Decorators Explained
  2. Decorator Metadata
  3. reflect-metadata and Design Types
  4. Building a Decorator Framework
← Back to TypeScript Academy