Skip to content

issue: Type error when used with zod v4Β #813

@shahinghasemi

Description

@shahinghasemi

Version Number

5.2.1

Steps to reproduce

import { z } from 'zod/v4';
import { zodResolver } from '@hookform/resolvers/zod';
import { useForm } from 'react-hook-form';


const schema = z.object({ name: z.string() });

  const methods = useForm({
    resolver: zodResolver(schema),
  });

Here's I can't use the schema inside the zodResolver, typescript complains:

No overload matches this call.
  Overload 1 of 4, '(schema: Zod3Type<{ name: string; }, { name: string; }>, schemaOptions?: ParseParams | undefined, resolverOptions?: NonRawResolverOptions | undefined): Resolver<...>', gave the following error.
    Argument of type 'ZodObject<{ name: ZodString; }, $strip>' is not assignable to parameter of type 'Zod3Type<{ name: string; }, { name: string; }>'.
      Types of property '_def' are incompatible.
        Property 'typeName' is missing in type '$ZodObjectDef<{ name: ZodString; }>' but required in type '{ typeName: string; }'.
 Overload 2 of 4, '(schema: $ZodType<unknown, FieldValues, $ZodTypeInternals<unknown, FieldValues>>, schemaOptions?: ParseContext<$ZodIssue> | undefined, resolverOptions?: NonRawResolverOptions | undefined): Resolver<...>', gave the following error.
    Argument of type 'ZodObject<{ name: ZodString; }, $strip>' is not assignable to parameter of type '$ZodType<unknown, FieldValues, $ZodTypeInternals<unknown, FieldValues>>'.
      The types of '_zod.version.minor' are incompatible between these types.
        Type '1' is not assignable to type '0'.ts(2769)

Heres my package.json:

"@hookform/resolvers": "^5.2.1",
"react-hook-form": "^7.62.0",
"typescript": "^5.9.2"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions