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 'X' does not exist on type CombinedVueInstance using TypeScript Prop Validator

See original GitHub issue

Version

2.5.16

Reproduction link

https://codepen.io/muhammadrehansaeed/pen/XPWKyJ

Steps to reproduce

Use Typescript to build this component:

export default Vue.extend({
  props: {
    delay: {
      default: 600,
      type: Number,
      validator: function(value: number) {
        return value >= 0;
      }
    },
    minValue: {
      default: 0,
      type: Number
    }
  },
  data() {
    return {
      valueInternal: 0
    };
  },
  methods: {
    reset(): void {
      this.valueInternal = this.minValue; <----THIS LINE ERRORS
    }
  }
});

What is expected?

The component builds.

What is actually happening?

The following error is thrown:

Property 'minValue' does not exist on type 'CombinedVueInstance<Vue, { isVisibleInternal: boolean; valueInternal: number; }, { reset(): void; }, {}, Readonly<{}>>'.
methods: {
  reset(): void {
    this.valueInternal = this.minValue;
                                               ^
  }
}

If I remove the validator from the prop, the error goes away. If I remove the data section, the error also goes away.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:9
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
pikaxcommented, Mar 18, 2019

if you do

    delay: {
      default: 600,
      type: Number ,
      validator(value:number){
        return value >= 0;
      }
    } as PropOptions<number>

seems to be working, typescript seems not picking up the type

1reaction
danjohnsocommented, Aug 19, 2019

I had this happen with a Date prop. If I had just the type, it was ok:

 date: {
    type: Date
}

But when I added a default value, everything broke in the component:

 date: {
    type: Date,
    default: () => new Date()
}

Unless you cast the object like mentioned above:

 date: {
    type: Date,
    default: () => new Date()
} as PropOptions<Date>

For anyone googling the seemingly unrelated error, you will get this for every property in your component:

Property ‘Name’ does not exist on type ‘CombinedVueInstance<Vue, object, object, object, Record<never, any>>’ Vetur(2339)

Read more comments on GitHub >

github_iconTop 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 >
Property 'xxx' does not exist on type CombinedVueInstance
I typed all return types of methods in computed / data. Typescript still says, that props being used in a method in computed...
Read more >
[Help] Property 'x' does not exist on type ... - Reddit
Hi! New to Vue/Nuxt. I am having an issue with Nuxt and TypeScript tutorial. Nuxt build throws these errors. ERROR in…
Read more >
[Solved]-How to fix "Property XX does not exist on type ...
Coding example for the question How to fix "Property XX does not exist on type 'CombinedVueInstance" errors in VSCode? (Vue with Typescript)-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 >

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