-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Conditional properties through discriminated unions and intersections in TypeScript #8952
Comments
Added another simple example with fully "exclusive" props that should be covered as well and does not work (yet). |
I ran into this many times, huge +1. |
Typescript allows me to use Conditional Types, but Vue doesn't allow me to do this |
C'mon Vue and TS NEED FULL SYNERGY. |
Hi guys, Any update here? @sxzz if you can please follow up on this issue. |
This is a type restriction of defineComponent, as a current solution you can use generic. This will bypass defineComponent and define the component as a functional component. <script setup lang="ts" generic="T">
interface CommonProps {
size?: 'xl' | 'l' | 'm' | 's' | 'xs'
}
// ...
</script> |
Unfortunately vue-test-utils does not support generic components with Typescript |
@johnsoncodehk while props with a discriminator work now in the playground (e.g. |
Any updates on the plans for this? |
What problem does this feature solve?
#7553
Reopening this because I believe the problem is not solved. It is still impossible to use coditional props.
Just try this after
npm create vue@latest
inside HelloWorld componentand then try to use it
Theoretically it should not allow us to use both. That is, there can't be color="white" appearance="text" only color="white" appearance="outline"
What does the proposed API look like?
The text was updated successfully, but these errors were encountered: