feat(types): export ProductObjectSchema and extractObjectSchema to restore .extend() on intersection schemas#1971
Draft
bokelley wants to merge 2 commits into
Draft
Conversation
…store .extend() on intersection schemas ProductSchema changed from ZodObject to ZodIntersection in 8.1.0-beta.* to accommodate V1/V2 format variants, silently breaking .extend()/.omit()/.pick() callers. Adds two additive non-breaking exports: - ProductObjectSchema: concrete ZodObject export for the documented use case - extractObjectSchema(): generic helper for any ZodIntersection<L, ZodObject<R>> Includes a runtime guard that throws a readable error if the codegen ever changes the intersection side that holds the ZodObject, and a canary test in test/lib/zod-schemas.test.js. Also fixes two broken examples in docs/ZOD-SCHEMAS.md (ProductSchema.extend() and ProductSchema.passthrough() both fail on ZodIntersection in 8.1+). Closes #1970 https://claude.ai/code/session_01A2Thvmn8bFTS5gvJixQS2P
Auto-updated by sync-version.ts during build gate run. https://claude.ai/code/session_01A2Thvmn8bFTS5gvJixQS2P
This was referenced May 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1970
Summary
ProductSchemachanged fromZodObjecttoZodIntersectionin 8.1.0-beta.* to accommodate V1/V2 format variants, silently breaking any downstream that called.extend(),.omit(), or.pick()on it directly. This PR restores the ergonomics via two additive, non-breaking exports and fixes two broken examples in the docs.New exports:
ProductObjectSchema— concreteZodObjectfor the most common case (ProductSchema.extend(...)→ProductObjectSchema.extend(...)). Directly replaces the documented pattern.extractObjectSchema(schema)— generic helper that extracts the right-sideZodObjectfrom anyZodIntersection<L, ZodObject<R>>produced by the codegen, for the other 96 intersection-shaped schemas in 8.1+.Docs fixed:
docs/ZOD-SCHEMAS.md— corrected the brokenProductSchema.extend(...)example in the Advanced Usage section.docs/ZOD-SCHEMAS.md— corrected the brokenProductSchema.passthrough()example in the Troubleshooting section (.passthrough()is alsoZodObject-only).Both exports include JSDoc examples and are available at
import { ProductObjectSchema, extractObjectSchema } from '@adcp/sdk'.What was tested
tsc --project tsconfig.lib.json --noEmit— clean (pre-existing deprecation warnings only, unrelated to this change)prettier --check— clean on all changed filestest/lib/zod-schemas.test.jsverifying:ProductObjectSchemahas.extend,.omit,.pickProductObjectSchema.extend({ _test_field: z.string() }).safeParse(...)succeeds on a valid productextractObjectSchema(ProductSchema)returns aZodObjectwith.extendProductSchema._def.rightexists, so a future codegen shape change surfaces as a readable test failure rather than a silent runtime errorPre-PR review
schema-helpers.ts→ named export intypes/index.ts→export * from './types'inindex.ts); runtimeinstanceofguard added per review feedback; canary test strengthened with_def.rightpre-assertion.*Schemaconventions; doc examples corrected including thepassthrough()case that was equally broken;TS2339 → ProductObjectSchemamapping added.Notes (not blocking)
migration-8.0-to-8.1.mddoc doesn't exist yet. Developers upgrading from 8.0 will find the fix via the correctedZOD-SCHEMAS.mdexample, but a migration doc would be a useful follow-up.extractObjectSchemadoes not handle chained intersections (.and().and()) — TypeScript's type system will surface this at compile time since the argument type won't matchZodIntersection<L, ZodObject<R>>.Session: https://claude.ai/code/session_01A2Thvmn8bFTS5gvJixQS2P
Generated by Claude Code