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

fix(types): align error object types with JS object structure #4961

Merged
merged 3 commits into from
Dec 22, 2024

Conversation

Thomaash
Copy link
Contributor

@Thomaash Thomaash commented Dec 12, 2024

🔎 Overview

This PR aligns types of errors object destructured from useForm with the JS object that is actually returned (the issue is described in more detail in #4295).

🤓 Code snippets/examples (if applicable)

Before:

type Step = {
  name: string
}

type Form = {
  steps: Step[]
}

type Result = Path<Form> // `steps` | `steps.${number}` | `steps.${number}.name`, fails at runtime

Now:

type Step = {
  name: string
}

type Form = {
  steps: Step[]
}

type Result = Path<Form> // `steps` | `steps[${number}]` | `steps[${number}].name`, works at runtime

Issues affected

closes #4295

Copy link

changeset-bot bot commented Dec 12, 2024

🦋 Changeset detected

Latest commit: 53e1de3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
vee-validate Patch
@vee-validate/joi Patch
@vee-validate/nuxt Patch
@vee-validate/rules Patch
@vee-validate/valibot Patch
@vee-validate/yup Patch
@vee-validate/zod Patch
@vee-validate/i18n Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

The `''` type only makes sense for errors (the top level errors). But
the Path type is also used in other places so it shouldn't add it.
Copy link
Owner

@logaretm logaretm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks for tackling this, LGTM. I worry it may cause breaking changes, but since the errors object currently is typed incorrectly, I think this is fine to have.

@logaretm logaretm merged commit 721e980 into logaretm:main Dec 22, 2024
5 checks passed
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

Successfully merging this pull request may close these issues.

Types problem with different path syntax
2 participants