The Wayback Machine - https://web.archive.org/web/20220305023403/https://github.com/angular/angular/issues/43253
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check generic types when using ViewChild/ContentChild and through DI #43253

Open
samuelfernandez opened this issue Aug 25, 2021 · 6 comments
Open

Comments

@samuelfernandez
Copy link

@samuelfernandez samuelfernandez commented Aug 25, 2021

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.

@ngbot ngbot bot added this to the needsTriage milestone Aug 25, 2021
@ngbot ngbot bot added this to the needsTriage milestone Aug 25, 2021
@alxhub alxhub added the feature label Sep 2, 2021
@ngbot ngbot bot removed this from the needsTriage milestone Sep 2, 2021
@ngbot ngbot bot added this to the Backlog milestone Sep 2, 2021
@angular-robot
Copy link

@angular-robot angular-robot bot commented Sep 3, 2021

This feature request is now candidate for our backlog! In the next phase, the community has 60 days to upvote. If the request receives more than 20 upvotes, we'll move it to our consideration list.

You can find more details about the feature request process in our documentation.

@angular-robot
Copy link

@angular-robot angular-robot bot commented Oct 13, 2021

Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.

Find more details about Angular's feature request process in our documentation.

@angular-robot
Copy link

@angular-robot angular-robot bot commented Nov 19, 2021

Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.

We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.

You can find more details about the feature request process in our documentation.

@Harpush
Copy link

@Harpush Harpush commented Dec 30, 2021

This will be awesome! Correct me if I am wrong but that will allow typing context variables on content child template too. A very much needed feature

@alxhub alxhub added this to Inbox in Feature Requests via automation Feb 1, 2022
@alxhub alxhub moved this from Inbox to Needs Project Proposal in Feature Requests Feb 1, 2022
@alxhub
Copy link
Contributor

@alxhub alxhub commented Feb 1, 2022

This has always been on the list for template type-checking.

@angular-robot
Copy link

@angular-robot angular-robot bot commented Feb 1, 2022

Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.

We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.

You can find more details about the feature request process in our documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Feature Requests
Needs Project Proposal
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants