type of useTemplateRef on generic components only contains exposed functions #5120
Labels
bug
Something isn't working
good reproduction ✨
This issue provides a good reproduction, we will be able to investigate it first
🔨 p3-minor-bug
Vue - Official extension or vue-tsc version
2.2.0
VSCode version
1.96.2
Vue version
3.5.13
TypeScript version
5.7.3
System Info
No response
package.json dependencies
No response
Steps to reproduce
Hi, I noticed that the type of a template ref created on a generic component is different from normal components. I have a specific usecase where I need to access the underlying component of the template ref using
$el
on it. This works as expected for all components except if the component is generic. In this case the type of the template ref will only contain the functions exposed from the component usingdefineExpose
.I created a reproduction inside a newly created vue app: https://github.com/markbrockhoff/vue-bug-repros/blob/main/src/App.vue
Steps to reproduce:
pnpm i
)pnpm type-check
to see the TS error when trying to access$el
on the template refcomponents/Example.vue
not generic by removinggeneric="T"
from its script tagpnpm type-check
again and see that the types are now as expectedWhat is expected?
I'd expect that the type for a template ref created on a generic component behaves the same was as when creating one. It should at least be of type
HtmlElement & ExposedFunctions
instead of justExposedFunctions
.What is actually happening?
Only the functions exposed from the generic component using
defineExpose
are present inside the type of the template ref.Link to minimal reproduction
https://github.com/markbrockhoff/vue-bug-repros/blob/main/src/App.vue
Any additional comments?
No response
The text was updated successfully, but these errors were encountered: