0Pricing
Frontend Academy · Lesson

Decorators and Metadata

Enable experimental decorators, write class, method, and property decorators, and use reflect-metadata for dependency injection patterns.

What Are Decorators?

Decorators are functions that modify classes, methods, properties, or parameters at definition time. They're used heavily in Angular, NestJS, TypeORM, and class-based MobX.

Decorator Syntax

Prefix a class, method, property, or parameter with @DecoratorName. The decorator function runs when the class is defined.

@Component({ selector: 'app-root' })
export class AppComponent {
  @Input() title: string;

  @HostListener('click')
  onClick() {
    console.log('clicked');
  }
}

All lessons in this course

  1. Template Literal Types
  2. Decorators and Metadata
  3. TypeScript with React: FC generics hooks
  4. Strict Mode and Eliminating any
← Back to Frontend Academy