-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
Support passing generic to child components #8015
Comments
This is an issue that requires consideration. In my opinion, using For slots, see #7982 (comment) /cc @johnsoncodehk |
I have same requirements |
Much needed feature |
附议。很需要这个功能,团队不方便用jsx |
+1 for this |
I just stumbled upon this issue, but unfortunately, there's no solution yet. This issue has been open for over a year; it's quite a specific problem and might not be resolved anytime soon.. |
What problem does this feature solve?
We can pass type parameter in TypeScript via generics:
But we cannot do so in Vue template.
To make this possible, we need the ability to restrict what components can be in slot:
also, now we have ability to prevent developer from putting unexpected components in slots!
Sometimes TypeScript cannot infer acutal type we want:
buttons
will infer asstring[]
, and@click
handle is(value: string) => void
, but we needFoods[]
and(value: Foods) => void
So we also need ability to specify what type we want:
What does the proposed API look like?
For template:
For slot type definition:
The text was updated successfully, but these errors were encountered: