Skip to content

Fix compatibility with latest version of @hookform/resolvers#11186

Merged
ThieryMichel merged 2 commits intomasterfrom
fix-@hookform/resolvers-compat
Mar 10, 2026
Merged

Fix compatibility with latest version of @hookform/resolvers#11186
ThieryMichel merged 2 commits intomasterfrom
fix-@hookform/resolvers-compat

Conversation

@slax57
Copy link
Contributor

@slax57 slax57 commented Mar 10, 2026

Problem

Using latest version of @hookform/resolvers and zod raises TS errors due to the type of the <Form resolver> prop being incompatible.

image

Solution

Properly forward the RecordType from FormProps (RA type) to UseFormProps (RHF type), and use FieldValues by default (just like they do).

This allows to:

  1. Fix the TS error by default (when providing no type parameter to <Form>)
  2. Provide a type parameter to <Form> to ensure proper type validation (as recommended in the RHF resolver example with ZOD + TS)

Additional Info

This PR also bumps the version of @hookform/resolvers and zod to make it easier to check compatibility with latest versions of these deps.

I also tried to bump yup to the latest version but failed. I stumbled across this issue: react-hook-form/resolvers#807. Hopefully it gets fixed at some point (feel free to upvote!).

How To Test

You can play with the following stories in packages/ra-core/src/form/Form.stories.tsx:

  • ZodResolver
  • ZodResolverWithSchema
  • YupResolver

The stories should run and show validation errors as expected. But to test the TS implementation, you'll probably need to edit the code to play around.

Additional Checks

  • The PR targets master for a bugfix or a documentation fix, or next for a feature
  • The PR includes unit tests (if not possible, describe why)
  • The PR includes one or several stories (if not possible, describe why)
  • The documentation is up to date

Also, please make sure to read the contributing guidelines.

@slax57 slax57 added the RFR Ready For Review label Mar 10, 2026
@ThieryMichel ThieryMichel added this to the 5.14.4 milestone Mar 10, 2026
@ThieryMichel ThieryMichel merged commit 6bb138d into master Mar 10, 2026
15 checks passed
@ThieryMichel ThieryMichel deleted the fix-@hookform/resolvers-compat branch March 10, 2026 13:42
@slax57 slax57 mentioned this pull request Mar 10, 2026
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

RFR Ready For Review

Development

Successfully merging this pull request may close these issues.

2 participants