The @Component({})
line in a component .ts file is referred to as a Decorator. Is this in relation to the Decorator Pattern, or are they unrelated?
Typescript decorator:
It’s compile time. It’s one time but permanent change, as the class that get decorated is different from the original class. And it's simple, basically just a function.
The common scenario is one decorator apply on different classes. For example: in Angular , the @injector decorator apply on various classes and make them injectable.
For the general decorator pattern:
The common scenario is different decorators on one single class. It’s pretty heavy-lifting. You need to create decorator class, common parent class for decorator class and original class, and different child decorator classes. The original class remains unchanged and you can apply decorator as see fit during run time.
Example: you have a coffee class. You can create different decorator classes: Espresso , Cappuccino, even expresso + Cappuccino coffee if you want.
Just my 2 cents.