Decorators in TypeScript
Decorators are a very cool functionality, initially proposed by Google in AtScript (a superset of TypeScript that finally got merged into TypeScript back in early 2015). They are a part of the current standard proposition for ECMAScript 7. In a nutshell, decorators are a way to add metadata to class
declarations for use by dependency injection or compilation directives. By creating decorators, we are defining special annotations that may have an impact on the way our classes, methods, or functions behave or just simply altering the data we define in fields or parameters. In that sense, they are a powerful way to augment our type's native functionalities without creating subclasses or inheriting from other types. It is, by far, one of the most interesting features of TypeScript. It is extensively used in Angular when designing directives and components or managing dependency injection, as we will learn later in Chapter 4, Enhance Components with Pipes and...