I need to be able to compose an Angular 2 component from several re-usable classes. As such, I'm attempting to implement Mixins using these guides:
https://www.typescriptlang.org/docs/handbook/mixins.html
Here's an abbreviated version of my code. I have multiple mixin classes, so I can't just extend another class:
//date-of-birth-form.ts
export class DateOfBirthForm {
dobMonth: number = null;
. . .
}
//registration-form.component.ts
@Component({
templateUrl: './registration-form.component.html',
})
@Mixin([DateOfBirthForm, ...])
export class RegistrationFormComponent implements DateOfBirthForm {
. . .
}
the problem I'm getting is:
[ts] Class 'RegistrationFormComponent' incorrectly implements interface 'DateOfBirthForm'. Property 'dobMonth' is missing in type 'RegistrationFormComponent'.
What am I doing wrong? Basically what I need to do is add form groups to a parent form, however some of the form components call web services or call local methods to calculate data that I'd like to encapsulate in the Mixin classes.