Skip to main content
D
TypeScript
TypeScript Decorators

TypeScript Decorators

Decorators attach special behavior to classes and functions.

Read Time
5 min read
Difficulty
Beginner
Last Updated
Jun 15, 2026
Version
v1.0.0

Introduction

A Decorator is a special type of declaration that attaches extra features to a class or a function without changing its internal code. You often see them used heavily in popular frameworks like Angular or NestJS.

Example

Example
1/* this uses a decorator */
2@LogClassCreation
3class UserProfile {
4  constructor() {
5    console.log("Profile created");
6  }
7}

Key Points

  • Decorators always start with the `@` symbol.
  • They are an advanced, experimental TypeScript feature.
  • You must enable them manually in the `tsconfig.json` file.
  • They are essentially just functions that wrap other functions.

Up Next

Continue your journey with the next topic.

Go to TS Modules