Summary
In this chapter, we learned how to consume and implement the four available types of decorators (class, method, property, and parameter). We used decorators to mutate the original classes to understand how they work but we also learned that we should avoid using decorators to mutate the prototype of a class. We also learned how to create a decorator factory to abstract developers from the decorator types when they are consumed, how to pass configuration to a decorator, and how to use the reflection metadata API to access type information at runtime. As we have already mentioned, decorators in TypeScript are still an experimental feature, which doesn't mean that they are not ready for their usage in production systems but that their ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access