In my project, I have defined two Angular 4 component classes.
The first class, referred to as the superclass:
export class SectionComponent implements OnInit {
slides: SlideComponent[];
constructor() {
}
ngOnInit() {
}
}
And then there's the subclass:
export class FrontPageSectionComponent extends SectionComponent implements OnInit {
slides: SlideComponent[];
constructor() {
super();
}
ngOnInit() {
this.slides = [];
}
}
My goal is to create an array of instances of the superclass in my AppComponent...
export class AppComponent implements OnInit {
sections: SectionComponent[];
constructor() {
}
ngOnInit(): void {
this.sections = [
new FrontPageSectionComponent()
];
}
}
However, when attempting to do so, I encounter an error message:
TS2322: Type 'typeof FrontPageSectionComponent[]' is not assignable to type 'SectionComponent[]'. Type 'typeof FrontPageSectionComponent' is not assignable to type 'SectionComponent'. Property 'slides' is missing in type 'typeof FrontPageSectionComponent'.
I did not explicitly specify any types myself and a search within the codebase did not return any results for 'typeof FrontPageSectionComponent', leading me to believe that this issue stems from TypeScript inference mechanisms.