I have to fix a bug that some data is missing when sending the form. I have this typescript interface
_id: string
name: string
coords?: number[]
createdAt?: Date
updatedAt?: Date
deletedAt?: Date
}
these are my props:
props: {
data: {
type: Object as PropType<Location>,
default: () => ({
_id: null,
name: '',
createdAt: '',
updatedAt: ''
})
}
},
and this is how I´m creating the v-model:
const location = reactive({ ...props.data } as Location)
const rules = {
name: { required },
coords: { required }
}
const v$ = useVuelidate(rules, location)
And I´m having an error like this
Types of property 'name' are incompatible.
Type 'string' is not assignable to type 'Ref<any>'.
76 | coords: { required }
77 | }
> 78 | const v$ = useVuelidate(rules, location)
CodePudding user response:
As cords are required on rules, either set a default value for it or remove optional properties in the Location interface