-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
"Type instantiation is excessively deep and possibly infinite" when using Zod with React Hook Form and @hookform/resolvers #3987
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
Comments
Running into the exact same issue |
I can confirm, the problems start yesterday, after upgrading from 3.24.1 to 3.24.2, downgrading solves the problem! |
@antonius-dev Thanks ! |
Confirmed as well. Downgrading patch solved the issue for me. |
Same issue! |
In Turborepo we have a shared package which exports Schemas. Using the |
@taylor-lindores-reeves thanks. Unfortunately the most minor patches often cause issues like that with zod. |
Thanks. The problem occurs when I use version 3.24.3. |
If you use yarn you can use My take is that external libraries should always be using zod as a peerDependency to avoid such conflicts. |
I have been using the zod version 3.23.8 and react-hook-form 7.51.5 for a while to not have this problem. However, when we attempt to update to nextjs 15 and react 19, we HAVE to update react-hook-form and thus run into this problem again. Just like the simple schema of the OP, my schema is just:
Which shouldn't be excessively deep and possibly infinite. Is there really no way to tell react hook form that he should just swallow this message as a warning? |
Running into the exact same issue |
Thank you! @yleflour This solution works for me! |
In our case it was a conflict of versions (we had 3.42.3 pinned but some eslint dependency brought 3.42.4). Bumping pinned version to 3.24.4 resolved the issue). In case of pnpm running |
also fixed it by downgrading to 3.24.2. No nerves to investigate more at this point. |
For me, downgrading to |
This works for me:
|
When using
zod
,react-hook-form
, and@hookform/resolvers
, I encountered a TypeScript error:This happens when defining a schema with Zod and passing it to
@hookform/resolvers/zod
.Steps to Reproduce
useForm
:I fix it by downgrading Zod
3.42.2
to3.42.1
resolved the issue.Environment
The text was updated successfully, but these errors were encountered: