Open
<
8233
div class="Box-sc-g0xbh4-0 gRssIw">
Description
Which @angular/* package(s) are relevant/releated to the feature request?
compiler
Description
Imagine we have a parent component NgxOptions<T>
and a child NgxOption<T>
, with the following definition:
@Component({ /*...*/ })
export class NgxOptions<T> {
@Input() options: T[];
}
@Component({ /*...*/ })
export class NgxOption<T> {
@Input() display: (option: T) => string;
// Forced parent component to be of the same generic type
constructor(options: NgxOptions<T>) { }
}
<ngx-options [options]="options">
<!-- I'd expect the compiler and language service to enforce both components have the same generic type -->
<ngx-option [display]="displayOption"></ngx-option>
</ngx-options>
Proposed solution
It would be great to enforce type checking of components with a generic type when there is a relationship between them, such as ViewChild
/ContentChild
or injection
Alternatives considered
Right now the strict checking only applied to templates. However, it is only implemented for inputs/outputs, not for generic types in components when they are related.