Generic prop type resolves to non-generic type with runtime `defineProps` declaration
YaredFall opened this issue · comments
Vue version
3.4.31
Link to minimal reproduction
Steps to reproduce
Look at the RuntimeComp.vue
and TSComp.vue
compoents.
They have same generic prop value
with type T extends Record<string, unknown>
, but RuntimeComp
uses runtime props declaration, while TSComp
uses type declaration.
Now look at the App.vue
component. When you hover over value
prop, you can see that types are not the same.
TSComp.vue
properly inherits generic type ({ foo: 'bar'}
in the example) while RuntimeComp.vue
resolves type to Record<string, unknown>
, thus losing generic type
What is expected?
Both RuntimeComp.vue
and TSComp.vue
should resolve generic type to the same type ({ foo: 'bar'}
in the example) and should not lose generic type
What is actually happening?
RuntimeComp.vue
resolves to non-generic type (Record<string, unknown>
in the example)
System Info
No response
Any additional comments?
No response
Generics are only supported when using the type interface declaration
Hi @LinusBorg!
Would you care to explain why there is such a limilation and if there are plans to support all cases?
I always use the object syntax for defineProps
and up until recently(maybe a month or two prior) I was able to use generics this way.
Somewhere down the road it stopped working and started inferring them as unknown
.
Thanks for your time!