Using expose in options API breaks vue-tsc typing in templates in Vue 3.5 #5069
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.1.10
VSCode version
N/A
Vue version
3.5.13
TypeScript version
5.7.2
System Info
package.json dependencies
No response
Steps to reproduce
Write a component using the Option API, and use
expose
to expose some properties but not others. For example:What is expected?
This should pass, which it did in Vue 3.4.x
What is actually happening?
In Vue 3.5.x, this causes the following TypeScript error (both in VSCode and when running vue-tsc on the command line):
The same thing happens for everything (refs returned by setup, but also props and methods) that is not listed in the
expose
array. If you remove theexpose
array altogether, the error goes away.Link to minimal reproduction
No response
Any additional comments?
It appears that Vue 3.5.x changed something that led vue-tsc to type-check the template using the public-facing version of the component instance (which only contains exposed properties) when it should be using the internal-facing version of the component instance (which contains all properties returned from setup, as well as props etc).
I tried different versions of Vue, and it appears this issue was introduced between Vue 3.4.38 and 3.5.0-alpha.1, which makes me suspect vuejs/core@75c8cf6 might have caused this.
The text was updated successfully, but these errors were encountered: