Closed
Description
Vue version
3.3.4
Link to minimal reproduction
Steps to reproduce
Check Comp.vue
- in the template, the discriminated union can be inferred correctly. Not so in the script.
This is probably because withDefaults uses Omit
to combine the required and optional props and because Omit follows the following behavior: microsoft/TypeScript#31501.
I'm not sure why the discriminated union is inferred correctly in the template, though.
defineProps
itself, without defaults, works correctly - check Comp1.vue
.

What is expected?
Discriminated unions should work in scripts as well as in templates.
What is actually happening?
Only works in templates.
System Info
No response
Any additional comments?
No response