defineProps options object loses properties when using generics
Vue version
3.3.7 & 3.4.alpha
Link to minimal reproduction
Steps to reproduce
<script setup lang="ts" generic="T">
import { PropType } from 'vue'
const props = defineProps({
a: Object as PropType<T>,
b: {
type: Object as PropType<T>
},
c: {
type: Object as PropType<T>,
required: true,
}
})
props.a
props.b
props.c
</script>
What is expected?
The props to be declared correctly
What is actually happening?
Properties are been excluded from props, unless they are required 🤔
System Info
No response
Any additional comments?
No response
You should add the type
property to define the props
object.
<script setup lang="ts" generic="T">
import { PropType } from 'vue'
const props = defineProps({
a: {
type: Object as PropType<T>,
},
b: {
type: Object as PropType<T>,
},
c: {
type: Object as PropType<T>,
required: true,
},
})
props.a
props.b
props.c
</script>