-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Explicit type specification for component rendering <MyComponent<T> /> #7672
Comments
Yeah agreed this could be useful, I've run into it before (although for my use-case I've now just started using Hooks, which are easier to type). In the end I worked around it like this: class ConcreteComponent extends MyComponent<number> {}
<ConcreteComponent item={1} /> ...although that solution only works for class components, not functional components. Supported in TypeScript since 2.9: microsoft/TypeScript#22415 |
I have implemented parsing side #7675 |
This is something that's been on my list for a while, but I was never sure I would get to it. Thanks for looking into this, @goodmind! I will review as soon as I can. |
@goodmind will your PR also add support for something like:
|
@villesau, no, why? |
Would be useful with type definitions. |
Why not generic function? |
How would you express this:
|
|
Any movement on this? This is an awesome feature in Typescript. |
The PR just got merged, so I guess we'll see! |
Proposal
Now there is no possibility to explicitly specify the generic type for the component.
This syntax can solve the problem:
I can be rea
Use case
The text was updated successfully, but these errors were encountered: