Property 'xxx' does not exist on type CombinedVueInstance ?
See original GitHub issueVersion
2.5.17
Reproduction link
Steps to reproduce
- use vue-cli init a ts hello-world project .
- code like that
<script lang="ts">
import Vue from "vue";
export default Vue.extend({
name: "HelloWorld",
props: {
msg: String
},
data():any {
return {
wtf: this.initData(), // throw ts error : Property 'initData' does not exist on type 'CombinedVueInstance<Vue, {}, {}, {}, Readonly<{ msg: string; }>>'.
}
},
methods: {
initData():any {
return {
a: ''
}
},
},
});
</script>
What is expected?
How can i fix it ?
What is actually happening?
Property ‘initData’ does not exist on type ‘CombinedVueInstance<Vue, {}, {}, {}, Readonly<{ msg: string; }>>’.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:86
- Comments:56 (6 by maintainers)
Top Results From Across the Web
Property 'XXX' does not exist on type 'CombinedVueInstance ...
I created a vue component with TypeScript, and I'm getting this error in data() and in methods() : Property 'xxx' does not exist...
Read more >property 'yyy' does not exist on type 'combinedvueinstance ...
Coding example for the question Property 'XXX' does not exist on type 'CombinedVueInstance >>'-Vue.js.
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 'title' does not exist on type 'never' - You.com | The AI ...
Property 'XXX' does not exist on type 'CombinedVueInstance<Vue, {}, {}, {}, Readonly<Record<never, any>>>'. Asked May 6, 2019 • 28 votes 11 answers.
Read more >Getting Property 'x' does not exist on type .... .Vetur(2339) #1834
adding properties inside a component breaks the known data and computed props and says Property 'x' does not exist on type 'CombinedVueInstance<Vue, object, ......
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
EDIT: See @IAMtheIAM’s answer below
I had this error while working inside of a computed property. My data and computed were organized like this:
It would give me the same error (
Property myDataPoint does not exist on type CombinedVueInstance
…)However, when I declared what type would be returned by the function, the error went away: (look to the
trueOrFalse
computed property for the change)Hope this helps!
Since this appears to be only a typing issue and not a runtime issue, there is an (ugly?) workaround available: cast
this
as typeany
:Additionally omit the
()
to store a reference to the method that is executable outside of the current scope, e.g. if you pass it to a child via a prop.