derekbaker783
derekbaker783

Reputation: 9581

How can I resolve Vetur/Vuelidate error "'validate' does not exist in type 'ComponentOptions<Vue [etc.]"?

QUESTION: How can I resolve error 'validations' does not exist in type 'ComponentOptions<Vue [etc.] while using Vetur with Typescript also installed, all in VSCode?

BACKGROUND: I attempted to introduce Vuelidate into a single-file Vue component (by adding a validations property as per the docs). The project containing that component has TypeScript installed so that Vetur's intellisense is improved (but the <script> sections are using JavaScript). After introducing the validations prop, Vetur was displaying an error with the message highlighted in the above question, and intellisense was breaking for methods (such as mount()) that were calling other methods.

CODE: My code basically looks like the sample below, but one would need to install TypeScript to reproduce the Vetur error:

export default {
  data() {
    return {
      name: '',
    }
  },
  validations: {
    name: {
      required,
      minLength: minLength(4)
    },
  }
}

WHAT HAVE I TRIED: I tried adding @ts-ignore to the validations property, but intellisense is still broken for methods calling other methods.

Upvotes: 2

Views: 665

Answers (1)

derekbaker783
derekbaker783

Reputation: 9581

The solution is:

  • run npm install --save-dev @types/vuelidate
  • restart VSCode

Upvotes: 3

Related Questions