Open BlushingTomato opened 2 months ago
I cannot reproduce it. Could you provide a minimal reproduction?
I tried creating a minimal reproduction, but cannot seem to reproduce it outside of our main repo 😞
I noticed that it also only happens for some components, not all of them. I'll keep looking as to what could be causing this.
Actually managed to reproduce it, you can see it here:
Seems to happen on defineAsyncComponent
instances which do not have any props passed.
Enter the node_modules/.vue-global-types/vue_2.7_false.d.ts
file, add the following content before line 102:
: T extends () => any ? (props: {}, ctx?: any) => ReturnType<T>
+ : T extends (...args: any) => Promise<infer R> | void ? () => R
: T extends (...args: any) => any ? T
Could this solve your problem?
The vue_2.7_false.d.ts
file gets reset when I run the vue-tsc --noEmit
command, so it keeps happening. Can I use a flag to disable that behavior?
You can patch the @vue/language-core/lib/codegen/globalTypes.js
file as a temporary solution.
No, the issue sadly persists even after patching the file.
It solved your repro on my machine, so I don't how to confirm the issue that occurred on your main repository :(
I tested it on the repro on my machine too, where it failed 🤔
I've added : T extends (...args: any) => Promise<infer R> | void ? () => R
after line 124 inside codegen/globalTypes
, should I add it somewhere else?
Oh my god, I cannot read. I've added it before that line and now it works. I apologize for the inconvenience and thank you for the solution.
Hello, I stumbled upon the same issue. Looking forward to it being fixed!
The current solution is not elegant and may trigger other unexpected type inferences. We are currently unable to merge it into the main branch - please use the above workaround temporarily until then.
Vue - Official extension or vue-tsc version
2.1.4
VSCode version
1.92.2
Vue version
2.7.16
TypeScript version
5.5.4
System Info
No response
package.json dependencies
No response
Steps to reproduce
const Component = defineAsyncComponent(() => import('path/to/Component.vue'))
and use it within the template.vue-tsc --noEmit
What is expected?
The check passing succesfully.
What is actually happening?
The following TS error:
Link to minimal reproduction
No response
Any additional comments?
This issue started happening in 2.1.4, 2.1.2 seems to work fine.