DEV Community

Discussion on: Composing Angular Components with Typescript Mixins

Collapse
 
layzee profile image
Lars Gyrup Brink Nielsen

Awesome article, Giancarlo. Amazing!

One thing I've noticed when extending classes in Angular is that when we have constructor injected dependencies, we have to add a constructor to the top-most level class with the necessary dependencies to make Angular's dependency injection work.

Have you noticed this when using class-based mixins?

Collapse
 
gc_psk profile image
Giancarlo Buomprisco

Hi Lars, thanks a lot again!

If you use a Mixin, you don't really need to re-inject the dependency, but you do need to tell TS that the class to which the mixin is applied to does have that particular service/type.

For example, Angular Material uses interfaces such as "HasElementRef" (github.com/angular/components/blob...)