With a plethora of child components such as Child1Component
, how can the annotations be properly written for the extended parent class ParentComponent
?
/** Parent Component */
/** <----- How to annotate here? */
export class ParentComponent implements OnInit {
constructor(i: INJECTED1, otherParam: string) {
...
}
...
}
/** Child Component */
@Component({selector: ..., template: ..., styleUrls: ...})
export class Child1Component extends ParentComponent {
constructor(i: INJECTED1, j: INJECTED2) {
super(i, 'otherParam');
}
...
}
Previous attempts:
- Trying to annotate
ParentComponent
with@Directive()
seemed like a close match, but it felt incorrect as it's not truly an angular directive. Additionally, the linter did not approve without further file naming modifications. - Leaving
ParentComponent
unannotated resulted in the Angular Compiler throwing an error
.NG2007: Class is using Angular features but is not decorated
- Adding the annotation
@Component({template: ''})
toParentComponent
seemed like a better solution and pleased the linter with the file name. However, it caused issues with the angular compiler expecting all parameters ofParentComponent
to be injectables, which they're not since they are called by their superclass.