Open
Description
Vue version
3.5.13
Link to minimal reproduction
Steps to reproduce
Our specific issue is that when the runtime prop type missing, the Boolean Casting doesn't work as expected.
- Define a generic type like:
type Wrapped<T> = T | number | string:
- Create a component with type-only props, that uses the type:
<script lang="ts" setup>
const props = defineProps<{
wrapped?: Wrapped<boolean>;
}>();
</script>
- Try to use the boolean prop:
<template>
<Comp wrapped /> <!-- component acts like `wrapped` is undefined -->
</template>
- => The component acts like
wrapped
is undefined` - => See output, runtime-prop is missing:
const sfc = /@PURE/_defineComponent({
__name: 'Comp',
props: {
wrapped: {},
},
setup(__props) {const props = __props;
return (_ctx,_cache) => {
return (_openBlock(), _createElementBlock("div"))
}
}})
What is expected?
- primitive runtime prop should be inferred correctly from static, generic types
boolean
casting should work for these
What is actually happening?
The runtime prop is undefined, and the prop is not treated as a boolean
System Info
System:
OS: macOS 14.7.3
CPU: (10) arm64 Apple M1 Max
Memory: 1.05 GB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.13.1 - ~/.local/state/fnm_multishells/71295_1739433231412/bin/node
npm: 10.9.2 - ~/.local/state/fnm_multishells/71295_1739433231412/bin/npm
pnpm: 10.2.0 - ~/.local/state/fnm_multishells/71295_1739433231412/bin/pnpm
Browsers:
Edge: 132.0.2957.140
Safari: 18.3
Any additional comments?
We noticed that our boolean prop types were not recognized:
<template>
<Comp wrapped /><!-- wrapped should be `true` for the `Comp` instance, but is nullish -->
</template>