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

Typeerror when used with zod 3.23 #675

Open
ljukas opened this issue May 3, 2024 · 6 comments
Open

Typeerror when used with zod 3.23 #675

ljukas opened this issue May 3, 2024 · 6 comments

Comments

@ljukas
Copy link

ljukas commented May 3, 2024

Describe the bug
When used together with zod 3.23 it will throw type errors in the zodResolver() function, all schemas does this

To Reproduce
Use latest release of @hookform/resolvers with zod 3.23

Expected behavior
To work with zod 3.23

@nkovacic
Copy link

nkovacic commented May 13, 2024

After updating to zod 3.23.8 this issue started appearing for me.
Updating @hookform/resolvers to 3.3.4 does not help.

TypeScript error message:

Argument of type 'ZodObject<{ email: ZodString; }, "strip", ZodTypeAny, { email: string; }, { email: string; }>' is not assignable to parameter of type 'ZodType<any, any, any>'.
  The types of '_getOrReturnCtx(...).common.issues' are incompatible between these types.
    Type 'Zod.ZodIssue[]' is not assignable to type 'import("/web/node_modules/.pnpm/[email protected]/node_modules/zod/lib/ZodError").ZodIssue[]'.
      Type 'Zod.ZodIssue' is not assignable to type 'import("/web/node_modules/.pnpm/[email protected]/node_modules/zod/lib/ZodError").ZodIssue'.
        Type 'ZodInvalidUnionIssue & { fatal?: boolean | undefined; message: string; }' is not assignable to type 'ZodIssue'.
          Type 'Zod.ZodInvalidUnionIssue & { fatal?: boolean | undefined; message: string; }' is not assignable to type 'import("/web/node_modules/.pnpm/[email protected]/node_modules/zod/lib/ZodError").ZodInvalidUnionIssue & { fatal?: boolean | undefined; message: string; }'.
            Type 'ZodInvalidUnionIssue & { fatal?: boolean | undefined; message: string; }' is not assignable to type 'ZodInvalidUnionIssue'.
              Types of property 'unionErrors' are incompatible.
                Type 'Zod.ZodError<any>[]' is not assignable to type 'import("/web/node_modules/.pnpm/[email protected]/node_modules/zod/lib/ZodError").ZodError<any>[]'.
                  Type 'Zod.ZodError<any>' is not assignable to type 'import("/web/node_modules/.pnpm/[email protected]/node_modules/zod/lib/ZodError").ZodError<any>'.
                    Types of property 'issues' are incompatible.
                      Type 'Zod.ZodIssue[]' is not assignable to type 'import("/web/node_modules/.pnpm/[email protected]/node_modules/zod/lib/ZodError").ZodIssue[]'.
                        Type 'Zod.ZodIssue' is not assignable to type 'import("/web/node_modules/.pnpm/[email protected]/node_modules/zod/lib/ZodError").ZodIssue'.
                          Type 'ZodInvalidArgumentsIssue & { fatal?: boolean | undefined; message: string; }' is not assignable to type 'ZodIssue'.

@Ygilany
Copy link

Ygilany commented Jun 12, 2024

This issue goes away when downgrading @hookform/resolvers to ^2.0.0

@jorisre
Copy link
Member

jorisre commented Jul 3, 2024

Can you please provide a minimal reproducible example (e.g. a Codesandbox)?

@matart15
Copy link

"@hookform/resolvers": "3.9.0",
"zod": "3.22.4"

results type mismatch

"@hookform/resolvers": "3.9.0",
"zod": "3.23.8"

works.

Question.
Why do you keep separate zod code in this library? it is hard to tell which zod version it is compatible with
https://github.com/react-hook-form/resolvers/blob/master/zod/package.json

@DerTimonius
Copy link

I also encounter this issue with the latest versions of both zod and @hookform/resolvers. Wanted to create a Stackblitz to show the issue, but even with the same versions I can't reproduce it and now I'm confused...

@hhsl
Copy link

hhsl commented Dec 10, 2024

I also encounter this issue with the latest versions of both zod and @hookform/resolvers. Wanted to create a Stackblitz to show the issue, but even with the same versions I can't reproduce it and now I'm confused...

Don't know if this helps, but I could fix this just now by first downgrading @hookform/resolvers to v2 and then upgrading back to latest. So, maybe there is something weird happening during the resolution of dependencies while upgrading anything zod or zodresolver related.

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

No branches or pull requests

7 participants