Vuejs type inference does not work with TS 3.4.x
See original GitHub issueVersion
2.6.10
Reproduction link
https://github.com/Patcher56/ts3.4.x-vuejs-issue
Steps to reproduce
- create a new vue typescript project (without class syntax)
vue create test-ts
- open
src/components/HelloWorld.vue
- add a data variable and try to access it in a computed property
What is expected?
No errors (as the data is defined)
What is actually happening?
Typescript error 2339 telling me
Property 'test' does not exist on type 'CombinedVueInstance<Vue, {}, {}, {}, Readonly<{ msg: string; }>>'.
I think this has something to do with the changed type inference in Typescript 3.4.x.
Important: Change vetur settings to use workspace dependencies to show errors directly in vscode, else you will only get the error when using yarn serve
.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:10
- Comments:27 (12 by maintainers)
Top Results From Across the Web
Property 'XXX' does not exist on type 'CombinedVueInstance ...
Solution: i have added declaration to component. <script lang="ts"> import Vue from 'vue'; // Add ...
Read more >TypeScript with Composition API - Vue.js
If not using <script setup> , it is necessary to use defineComponent() to enable props type inference. The type of the props object...
Read more >Documentation - Type Inference - TypeScript
This kind of inference takes place when initializing variables and members, setting parameter default values, and determining function return types. In most ...
Read more >FAQ | Vetur - GitHub Pages
If you are getting a lot of Property 'xxx' does not exist on type 'CombinedVueInstance' errors, it's an issue with Vue's typing and...
Read more >property 'yyy' does not exist on type 'combinedvueinstance ...
Same issue is described here https://www.gitmemory.com/issue/vuejs/vue/9873/485481541. As its a problem with TS 3.4.x, 3.9.6 works very well for me now.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
One workaround is assigning a return type to computed
Best workaround is to use the new Vue Composition API. It is a lot cleaner for typescript and works also with typescript versions > 3.3.4000.