Property 'xx' does not exist on type 'Validation<ValidationArgs<unknown>, unknown>'
See original GitHub issueProperties 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:
- Created a year ago
- Reactions:4
- Comments:7 (5 by maintainers)
Top 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 >
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 Free
Top 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
@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?
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?