resolvers icon indicating copy to clipboard operation
resolvers copied to clipboard

Typeerror when used with zod 3.23

Open ljukas opened this issue 9 months ago • 3 comments

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

ljukas avatar May 03 '24 08:05 ljukas

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'.

nkovacic avatar May 13 '24 07:05 nkovacic

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

Ygilany avatar Jun 12 '24 15:06 Ygilany

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

jorisre avatar Jul 03 '24 07:07 jorisre