-
Notifications
You must be signed in to change notification settings - Fork 460
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
TS: 2339: Property 'xxx' does not exist on type 'CombinedVueInstance<Vue, object, object, object, Record<never, any>>' #2834
Comments
it's hard to debug this without a repository. Most of the time, TypeScript type checking complains the correct thing. I'd suggest you to try your codes with What does your IDE show about the type of One thing I noticed in your deps is: you are using jest 24 and |
I guess the reason why is |
|
ah ha, there you have your answer :) cc @lmiller1990 |
eh really? but why is ts-jest complaining about |
it is not |
ok, then what can be the cause of having one type in the editor on another type in the compiler? Could there be an error in a Transform of the .vue file and/or the .spec.ts file ? |
I think it's from a different spot. I think the stack trace should tell you some information. |
My guess is const wrapper: Wrapper<InstanceType<typeof SomeComponent>>;
expect(wrapper.vm.someprop) // <- you did not type `someprop`, so it doesn't exist What happens if you do: const wrapper = mount(SomeComponent, {
props: { /*...*/ }
}) That might work better - a lot of work has gone into inferring the type of This is assuming you are on Vue 3 - Test Utils and Vue 2 are written in JS, so getting true type safety is very complex and generally not realistic. Also, as a work around if you just need something to work, you can use (wrapper.vm as any).someProp |
it is Vue2 with composition api. I was just baffeled that the types I see in vscode and the one that gets checked deviates. |
related to vuejs/vue#8721 |
It also seems to be a race condition in vscode. Sometimes it shows as CombinedVueInstance somethimes with the other type. is that possible @lmiller1990 ? |
It seems like before the vue-composition-api |
Right now, I am unable to reproduce it myself. I'n now stuck at CombinedVueInstance also :( |
@lmiller1990 originally, yes, that complex type from above was, in my eyes, the correct one. Sadly now vscode and ts-jest agreed on torturing me with the CombinedVueInstance which doesn't work with |
🐛 Bug Report
I have a Vue project with Typescript where I also use vue-test-utils. So in order to test components a Wrapper is used. This looks like this most of the time:
Hence, the wrapper has a pretty extensive type now. But when I run jest, ts-jest is stating that
someprop
does not exist on typeCombinedVueInstance<Vue, object, object, object, Record<never, any>>
, but that is not the type of wrapper.vm.To Reproduce
Steps to reproduce the behavior:
Expected behavior
ts-jest should use the correct type.
Link to repo (highly encouraged)
Sorry, private project
Debug log:
envinfo
The text was updated successfully, but these errors were encountered: