Nâng CaoTypeScript iconTypeScript

Decorators trong TypeScript là gì?

Decorators là function đặc biệt apply lên class/method/property/accessor/parameter để modify behavior.

  • Dùng @decorator syntax.
  • TS 5.0+ hỗ trợ TC39 Stage 3 decorators natively (không cần flag).
  • Legacy decorators (Angular, NestJS) vẫn dùng experimentalDecorators: true — hai loại không tương thích.
  • Decorator factories: @Log() trả về decorator function.

Xem toàn bộ TypeScript cùng filter theo level & chủ đề con.

Mở danh sách TypeScript