question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Property 'xxx' does not exist on type CombinedVueInstance ?

See original GitHub issue

Version

2.5.17

Reproduction link

Steps to reproduce

  1. use vue-cli init a ts hello-world project .
  2. 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:open
  • Created 5 years ago
  • Reactions:86
  • Comments:56 (6 by maintainers)

github_iconTop GitHub Comments

244reactions
JaidenDeChoncommented, Aug 17, 2021

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:

export default Vue.extend({
    name: 'componentName',
    data() {
        return {
            myDataPoint: false,
        };
    },
    computed: {
        trueOrFalse() {
            return this.myDataPoint ? 'is-true' : 'is-false';
        }
    },
})

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)

export default Vue.extend({
    name: 'componentName',
    data() {
        return {
            myDataPoint: false,
        };
    },
    computed: {
        // declare the type returned by your function/computed/method
        trueOrFalse(): string {
            return this.myDataPoint ? 'is-true' : 'is-false';
        }
    },
})

Hope this helps!

67reactions
brandoncashcommented, Oct 10, 2018

Since this appears to be only a typing issue and not a runtime issue, there is an (ugly?) workaround available: cast this as type any:

return {
  wtf: (this as any).initData(),
};

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found