Skip to content

zodResolver() type overload fails with Zod v4.3.x due to branded version mismatch #842

@Asborien

Description

@Asborien

Bug report

zodResolver() from @hookform/resolvers/zod@5.2.2 fails TypeScript overload matching when used with zod@4.3.6.

Error

Type error: No overload matches this call.
  The types of '_zod.version.minor' are incompatible between these types.
    Type '3' is not assignable to type '0'.

Cause

The resolver's type overloads use Zod's branded version type (_zod.version.minor). The resolver was built against Zod 4.0.x where minor is 0, but Zod 4.3.x has minor as 3. The overload signature requires an exact literal match, so the types are incompatible.

The runtime code works correctly — it detects Zod v4 schemas and resolves them fine. Only the type-level overload matching is broken.

Reproduction

  1. Install zod@4.3.6 and @hookform/resolvers@5.2.2
  2. Create a schema: const schema = z.object({ name: z.string() }).pick({ name: true })
  3. Pass it to zodResolver(schema)
  4. Run next build on Node 24 (e.g. Vercel build environment)

The error does not always reproduce locally with Node 20 — it depends on module resolution behavior. Node 24 on Vercel triggers it reliably.

Expected behavior

zodResolver() should accept any Zod v4.x schema without requiring an exact minor version match in the type overloads.

Suggested fix

The version-branded overload types should use a range or less restrictive constraint for the minor version, so that patch/minor updates within Zod v4 don't break type compatibility.

Workaround

Wrap zodResolver with a type assertion:

const resolver = zodResolver(schema as any)

Versions

  • @hookform/resolvers: 5.2.2
  • zod: 4.3.6
  • react-hook-form: 7.x
  • typescript: 5.x
  • Node: 24 (Vercel build)

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