Type conflict: @ag-ui/core 0.0.49 (Zod 3) breaks consumer Zod 4 type checking
@tombeckenham is already working on this.
Since Sep 17, 2026.
- #738 by @tombeckenham — closed without merging
- Dominant language
- TypeScript
- Stars
- 3.1k
- Forks
- 331
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 160
Description
Problem
@tanstack/ai itself is on Zod 4 (^4.2.0), but pins @ag-ui/core@0.0.49 which still depends on zod: ^3.22.4. This pulls Zod 3 into the consumer's type graph as a transitive dep, even when the consumer's app is fully on Zod 4.
This breaks consumers using @hookform/resolvers/zod v5 (or any other library with Zod-3-vs-4 dual overload typings), because TypeScript's overload resolver compares two different zod/v4/core/versions.d.ts files in the same compilation:
- Zod 3.25.x's
v4/coreshim:version.minor: 0 - Zod 4.x:
version.minor: 3(or current)
Producing errors like:
error TS2769: No overload matches this call.
Overload 2 of 4, '(schema: \$ZodType<...>, ...): Resolver<...>', gave the following error.
The types of '_zod.version.minor' are incompatible between these types.
Type '3' is not assignable to type '0'.
Repro
- Install
@tanstack/ai(any recent version) - Install
@hookform/resolvers@5andzod@^4.3 - Run
tsc --noEmiton any file callingzodResolver(z.object({...}))
Tracking upstream
The right long-term fix is @ag-ui/core moving to Zod 4 — tracked in ag-ui-protocol/ag-ui#1397 (open, no ETA).
Suggested workarounds for @tanstack/ai
While #1397 is unresolved:
- Document the transitive Zod 3 footgun in the
@tanstack/aiREADME / migration notes so consumers know to expect resolver typing breakage. - Vendor or shim
@ag-ui/coretypes internally sozod/v3doesn't surface in consumer type graphs. - Or just push #1397 to land —
@tanstack/aiis the largest downstream consumer of@ag-ui/coreand your influence there would help.
Happy to PR #1 if useful.
Local workaround we used
Module declaration override in our app:
// types/hookform-resolvers.d.ts
declare module '@hookform/resolvers/zod' {
import type { FieldValues, Resolver } from 'react-hook-form';
export function zodResolver<TInput extends FieldValues, TContext = unknown, TOutput = TInput>(
schema: { _zod: { output: TOutput; input: TInput } } | { _output: TOutput; _input: TInput; _def: { typeName: string } },
schemaOptions?: unknown,
resolverOptions?: { mode?: 'async' | 'sync'; raw?: false },
): Resolver<TInput, TContext, TOutput>;
}
Runtime is fine — both Zod 3 and Zod 4 schemas are recognized at runtime by the resolver.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.