Vue version
3.5.31
Link to minimal reproduction
https://github.com/wuchunxu/vite-prop-runtime-repro
Steps to reproduce
After upgrading Vue from 3.5.21 to 3.5.31, runtime props inference from defineProps<T>() changed for a complex union type.
I have a prop type like this:
export type FormItemOptions<T = any, Context = any> =
MaybeRef<OptionItem[]>
| Promise<OptionItem[]>
| ((row: T, context: Context) => Awaitable<OptionItem[]>)
In built output, Vue generates runtime prop type as:
options: {
type: [Promise, Function],
default: () => []
}
Array is missing, so passing an array value triggers runtime warning:
[Vue warn]: Invalid prop: type check failed for prop "options". Expected Promise | Function, got Array
If I explicitly add OptionItem[] in the union (instead of relying only on MaybeRef<OptionItem[]>), the generated runtime type includes Array and warning disappears.
What is expected?
Runtime props inference should include Array branch (or at least not narrow in a way that rejects valid array values from MaybeRef<OptionItem[]>).
For this case, expected generated runtime type should include:
type: [Array, Promise, Function]
What is actually happening?
Generated runtime type is:
type: [Promise, Function]
which rejects array values at runtime.
System Info
Any additional comments?
This looks like a boundary case in SFC type-to-runtime props inference for complex union types involving MaybeRef<T[]>.
If this should be tracked in another Vue package (e.g. compiler-sfc), please let me know and I can move the issue with the same repro.
Vue version
3.5.31
Link to minimal reproduction
https://github.com/wuchunxu/vite-prop-runtime-repro
Steps to reproduce
After upgrading Vue from
3.5.21to3.5.31, runtime props inference fromdefineProps<T>()changed for a complex union type.I have a prop type like this:
In built output, Vue generates runtime prop type as:
Arrayis missing, so passing an array value triggers runtime warning:If I explicitly add
OptionItem[]in the union (instead of relying only onMaybeRef<OptionItem[]>), the generated runtime type includesArrayand warning disappears.What is expected?
Runtime props inference should include
Arraybranch (or at least not narrow in a way that rejects valid array values fromMaybeRef<OptionItem[]>).For this case, expected generated runtime type should include:
What is actually happening?
Generated runtime type is:
which rejects array values at runtime.
System Info
Any additional comments?
This looks like a boundary case in SFC type-to-runtime props inference for complex union types involving
MaybeRef<T[]>.If this should be tracked in another Vue package (e.g.
compiler-sfc), please let me know and I can move the issue with the same repro.