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 'xx' does not exist on type 'Validation<ValidationArgs<unknown>, unknown>'

See original GitHub issue

Properties defined in thevalidation()method are not recognized by typescript and so compilation fails

Expected behavior Properties defined in the validation()methods recognized as attributes of the v$ instance

Q: How to declare the properties under vuelidate validation valid v$ attributes?

Snippet:

<template>
   <div v-if="v$.xx.$error">xx error</div>
--> Property 'xx' does not exist on type 'Validation<ValidationArgs<unknown>, unknown>' <--
</template>

<script lang="ts">
import useVuelidate from '@vuelidate/core'
import { required } from '@vuelidate/validators'
export default defineComponent({
  setup() {
    const v$ = useVuelidate()
    return { v$ }
  },
  data() {
    return {
      xx: '',
    }
  },
  validations() {
    return {
      xx: { required },
    }
  }
}

Same error without thesetup() method and exposingv$indata():

data() {
    return {
      v$: useVuelidate(),
    }

package.json:

{
  "dependencies": {
    "@vuelidate/core": "^2.0.0-alpha.40",
    "@vuelidate/validators": "^2.0.0-alpha.28",
    "vee-validate": "^4.5.11",
    "vue": "^3.2.32",
  },
  "devDependencies": {
    "@types/vuelidate": "^0.7.15",
    "typescript": "^4.6.3",
    "vite": "^2.9.5",
  }
}

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:4
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
alexejrotarcommented, Jul 8, 2022

@jorparad are you using options API or composition API? I suppose you are using typescript, otherwise you wouldn’t get such an error. in that case I recommend using the composition API. i.e. create your data and rules inside your setup method, and call useVuelidate with these as arguments. see my previous comment for an example. if that won’t solve the problem, would you post a code snippet?

0reactions
jorparadcommented, Jul 8, 2022

I’m following the examples in the documentation using useVuelidate() inside setup() and getting this error.

How is the correct way of specifying the type if the way described in the documentation is not working?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Property 'XXXX' does not exist on type 'unknown'
I am sending in the props correctly, but still not able to receive the data(details) part from the useLocation . Can we get...
Read more >
Typescript Property XXX does not exist on type ... - Edureka
I'm working on a project with Typescript, React and Redux (all running in Electron), and I've run into a problem when I'm including...
Read more >
vscode中的vue项目报错Property 'xxx' does not exist on type ...
Property 'xxxx' does not exist on type 'CombinedVueInstance<{ readyOnly: unknown; businessPrice: unknown; travelStaffInfo: any; } ...
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