Introduction
In the previous chapters, you saw how to create types and classes and how to compose them into a proper class hierarchy using interfaces, inheritance, and composition.
Using the TypeScript type system, you can create some very elegant models of the domains of your applications. However, models do not live by themselves; they are part of a larger picture – they are part of an application. And classes need to be aware that they live in a larger world, with many other parts of the system running in tandem with them, with concerns that go beyond the scope of a given class.
Adding behaviors to or modifying classes to account for the preceding scenario is not always easy. And this is where decorators come to the rescue. Decorators are special declarations that can be added to class declarations, methods, and parameters.
In this chapter, we'll learn how you can use a technique called decorators to transparently add complicated and common behaviors to...