-
-
Notifications
You must be signed in to change notification settings - Fork 420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using expose in options API breaks vue-tsc typing in templates in Vue 3.5 #5069
Comments
It looks like the type returned by const Component = defineComponent( {
setup() {
const msg = ref( 'hello' );
const msg2 = ref( 'world' );
return { msg, msg2 };
},
expose: [ 'msg' ]
} );
const instance = new Component();
console.log( instance.msg );
console.log( instance.msg2 ); (note this code doesn't actually run, it throws a runtime error because In Vue 3.4.x, this code passes TypeScript, but in Vue 3.5.x TypeScript complains that |
We can't update to 3.5.x yet because of vuejs/language-tools#5069 , but for newer versions of TypeScript to work we do need the types for the toggle event on `<details>` to be correct, and 3.4.28 fixes that. Change-Id: I9c90a90b58076e18fb1dc594effa73662123568d
Temporarily comment out `expose` in the components that use it, until vuejs/language-tools#5069 is resolved. Bug: T374140 Change-Id: I358722b602cedb88075df681a4d677abb10fe5b5
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: