Decorators

Decorators are a stage 2 proposal feature for JavaScript and are available as an experimental feature of TypeScript. Decorators, at their core, are just functions. Such functions can be used on different kinds of declarations, such as classes and their members, as well as parameters.

Decorators can emit metadata that can be inspected later by other code or processes, enabling a meta-programming style. Considering your background in .NET, you can think about TypeScript decorators as .NET attributes. Unlike .NET attributes, though, decorator functions can actually manipulate the decorated code.

Decorators are considered a somewhat advanced feature of TypeScript and there's much to learn in that regard. The depth of this feature is ...

Get Hands-On Full-Stack Web Development with ASP.NET Core now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.