Follow zod guidance on supporting v4 - for users incrementally migrating from v3#158
Follow zod guidance on supporting v4 - for users incrementally migrating from v3#158Sam152 wants to merge 2 commits into
Conversation
|
Investigated the CI failure — it's an OOM in Reproduced locally: Root causeThis PR switches Bisect
Suggested fixUpdate the 8 test files to also import from After that, one real v4 API issue surfaces at Side note: master is also currently red, but for a different reason — #157 introduced |
|
Hi @cpimhoff — thanks for the work on this! I've opened #161 which builds on your PR:
Closing this in favor of #161 — full credit to you for the original migration. 🙏 |
* Progress * Progress * test: align test files with zod/v4 imports and fix examples typing Test files were importing z from 'zod' while src/ now imports from 'zod/v4'. TypeScript treats those as nominally distinct types, and the mismatch causes type instantiation to explode through tRPC's generic machinery, OOMing tsc. Also cast the named-object examples in the multipleExamples test to preserve existing runtime behavior — zod-openapi v5 types meta examples as unknown[], but the runtime still accepts the v3-style record form. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * refactor: split type-only zod/v4 imports and drop unused ZodTypeAny Addresses Copilot review on #161: - ZodSchema, ZodObject, ZodAny, ZodRawShape, ZodType, ZodError are only used in type positions — move them to `import type` so stricter TypeScript settings (verbatimModuleSyntax, preserveValueImports) don't emit unused value imports. - ZodTypeAny was imported in node-http/core.ts but never referenced — remove it. - Replace the broad `as never` cast on the multipleExamples test with `as unknown as unknown[]` plus a comment explaining why the runtime still accepts the v3-style named-record form. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Sam <Sam152@users.noreply.github.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
I think you got me mixed up with @Sam152 😄 but I'm certainly happy to see this change! |
This PR does not add support for zod v3, but instead makes the integration of this package gentler on folks with large v3 codebases, trying to incrementally adopt v4.
In the zod docs for package authors it describes the following:
Importing from
zod/v4acts as a permalink to the v4 version, essentially allowing either v3 or v4 to be installed - but maintaining the direct dependencies on actual v4 code.