adapter-react-hook-form
adapter-react-hook-form copied to clipboard
Type instantiation is excessively deep and possibly infinite.
When passing a zod schema to the zodResolver like this:
const schema = useUpdateNameSchema();
const { form, handleSubmitWithAction } = useHookFormAction(
updateName,
zodResolver(schema),
{
formProps: {
defaultValues: {
name: user?.name || "",
},
},
},
)
It throws this error: Type instantiation is excessively deep and possibly infinite.
Without knowing much about this particular issue, this "Excessively deep" issue is likely fixed in Zod 4.1.6: https://github.com/colinhacks/zod/pull/5222.
If you are using Zod 3.x, you can fix this issue by updating your tsconfig to use a modern module/moduleResolution setting instead of the legacy "node": https://x.com/colinhacks/status/1966261915115782654
To the maintainers: if you haven't already, I recommend checking out the Library Authors guide for best practices around peer dependencies and accepting user-defined schemas: https://zod.dev/library-authors