You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
declare module 'zod' augmentation breaks when third-party packages load both 'zod' and 'zod/v4' subpaths #379
The declare module 'zod' augmentation on ZodType breaks when third-party packages cause TypeScript to load both the top-level zod entry point and the zod/v4 subpath. The top-level zod exports a v3-compat ZodType<Output, Def, Input>, while zod/v4 exports the native v4 ZodType<Output, Input, Internals>. TypeScript merges both into a single ZodType with incompatible type parameters, causing .openapi() to disappear from all schemas.
Minimal repro: install zod@^4 + zod-to-openapi@^8 + langchain + better-auth (or any package whose .d.ts loads zod/v4). npx tsc --noEmit fails. Remove any one of the three ingredients and it passes.
changed the title [-]declare module 'zod' augmentation breaks when third-party packages import from zod/v3[/-][+]declare module 'zod' augmentation breaks when third-party packages load both 'zod' and 'zod/v4' subpaths[/+]on Apr 8, 2026
Activity
[-]declare module 'zod' augmentation breaks when third-party packages import from zod/v3[/-][+]declare module 'zod' augmentation breaks when third-party packages load both 'zod' and 'zod/v4' subpaths[/+]