You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Typescript supports type inference in cases like this. Here is another, non-Vue example which works:
typeexampleProps<T>={setup: (props: {multiplier: string})=>T}functiondefineComponent<T>(component: exampleProps<T>){returncomponent;}functioncreateExtendableSetup<PROPS,SETUP_RESULT>(setupFn: (props: PROPS)=>SETUP_RESULT){returnsetupFn;}consttestWithCreateExtendableSetup=defineComponent({setup: createExtendableSetup((props/* PROPS is typed correctly */)=>{// This is a correct inferred string value, even when used in the return methodconstfoo=props.multiplier;return{
foo
}}),})
So Vue should also be able to inference the "props" types correctly.
What is actually happening?
The inference is broken when a wrapping method is used. See the Github Commit example or the Playground example.
System Info
No response
Any additional comments?
We want to write a extension system for Vue components and therefore need to wrap the setup method like this:
Vue version
3.5.6
Link to minimal reproduction
https://play.vuejs.org/#eNqdU21r2zAQ/iuHPiUlxJTtU5YEthHGxmhNkn4TDMc+x25lSeilSTH+7ztLTurB6EaFEae7R4+ee3HLPms9f/bIFmxpc1NrByKTxxVnznK25jJJ4BtKNJmAk8k0NOgqVUCpDFh0XsOpqvMKbKW8KKCWJRpwFYI2SltwLxot5MoYzJ144bL0Mne1koFsmW7v090Mdpv9Q/pru9k9/NyvJ4F2AZPAsICAmcJq/Qds+i8AtFwCGOIyMirlsuOSSzxrZRwUWGZeuAgbmILdr+zONwc0KblH3n71CS0ghmfjwMC3gNuruwtW3Iek+qwnUXhQPHBTkfdVbS9VPGB4R5XDQ3DwLhQ1lBdlTpYFqRyclHmq5TGy5EpawiFtq5jSfJTIpwgaKtJSLUjbNIi7PE/fiDC5iaovcv9TayaLwGLfLQpuktCrZRInkqaQDg4bLTKHdAJYVrfrth33CbpumZC3vzaCshkNMmko6+P80SpJcx7y4CxXja4FmnvdzyMN+7XTnGVCqNOP4HPG49BRulNh/vQX/6M99z7OUoMWzTNydo25zBzRxfBmd4dnsq/BRhVeEPqN4BatEr7XGGFfvCxI9ggX1H5v+rGm1u3t5uxQ2ktSvdDXOeSMfvavb6T+KvfD/GO4R71g3W/jgV88
Steps to reproduce
Look at these DTS test: 348d9c6
This should be green but it is not working.
What is expected?
Typescript supports type inference in cases like this. Here is another, non-Vue example which works:
So Vue should also be able to inference the "props" types correctly.
What is actually happening?
The inference is broken when a wrapping method is used. See the Github Commit example or the Playground example.
System Info
No response
Any additional comments?
We want to write a extension system for Vue components and therefore need to wrap the setup method like this:
Our implementation is working fine. The only problem is that the types of the arguments are getting lost.
The text was updated successfully, but these errors were encountered: