Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The types for the errors when using useFieldArray are incorrect #4721

Open
5 tasks done
OguzcanKarakoc opened this issue Apr 2, 2024 · 0 comments
Open
5 tasks done

Comments

@OguzcanKarakoc
Copy link

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?

  • Firefox
  • Chrome
  • Safari
  • Microsoft Edge

Relevant log output

No response

Demo link

...

Code of Conduct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant