vee-validate icon indicating copy to clipboard operation
vee-validate copied to clipboard

The types for the errors when using useFieldArray are incorrect

Open OguzcanKarakoc opened this issue 11 months ago • 0 comments

What happened?

const {
  handleSubmit,
  values,
  errors,
} = useForm(
  {
    validationSchema: toTypedSchema(schema),
    initialValues: {
      people:[{name: 'John'}]
    }
  })

According to the types the errors should be

<input  ... :error-messages="errors[`people.${index}.name`]" />

But in reality it is

errors: {
  "people[0].name": "Required",
  "people[1].name": "Required"
}

yet writing this gives me a typescript error

<input  ... :error-messages="errors[`people[${index}].name`]" />
Element implicitly has an 'any' type because expression of type '`people[${number}].businessName`' can't be used to index type 'Partial<Record<"people" | `people.${number}` | `people.${number}.name` | `people.${number}.businessName` | `people.${number}.country` | `people.${number}.contactEmail` | `people.${number}.contactPerson` | `people.${number}....'.ts(7053)

Reproduction steps

...

Version

Vue.js 3.x and vee-validate 4.x

What browsers are you seeing the problem on?

  • [X] Firefox
  • [X] Chrome
  • [X] Safari
  • [X] Microsoft Edge

Relevant log output

No response

Demo link

...

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

OguzcanKarakoc avatar Apr 02 '24 14:04 OguzcanKarakoc