Summary
In this chapter, you looked at a technique called decorating that is natively supported in TypeScript. The chapter first established the motivation for the use of decorators and then looked at the multiple types of decorators in TypeScript (class, method, accessor, property, and parameter decorators), along with examining the possibilities of each. You learned how to swap or change the complete constructor of a class with a class decorator, how to wrap a single method or property accessor with a method decorator, and how to enrich the available metadata using property and parameter decorators.
The chapter also discussed the differences between active and passive decorators, which boil down to a difference between code and definition. You implemented several common variants of each of the decorator types and demonstrated how different decorator types can nicely complement each other. This chapter should help you easily manage the usage and creation of decorators both...