I agree a bit with typescript decorators and how they are explained. Presumably, they “decorate” the class by associating metadata with it. I really cannot understand how this metadata is then associated with an instance of the class. Take the angular 2 example.
@Component(
{
selector:...
}
)
export class foo { ... }
Currently, as I understand it, angular will create an instance of the foo class and somehow associate the instance with decorator arguments so that it can provide services, directives and templates. All this, it seems, can also be implemented through class inheritance. If I have a Component class and make my component an extension of this class, why not angular, then provide these arguments when it loads in a way that responds to the details, and completely get rid of the decorators in this use case.
class Component { ... }
class Foo extends Component { ... }
then you must create an instance, at boot / start with this
new Foo(ElementName, Directives, Services, etc..)
With the reaction, this is technically what went on under the hood. You got the component and implemented its methods. If you need to transfer information when creating an instance, then you pass the props object.
please enlighten me.