Skip to content

fix(codegen): extend TS7056 list for 3.1.0-beta.2 compound schemas — foundation now builds clean - #1912

Closed
bokelley wants to merge 1 commit into
bokelley/cut-8-0-betafrom
bokelley/codegen-zod-ts7056-fix
Closed

bokelley wants to merge 1 commit into
bokelley/cut-8-0-betafrom
bokelley/codegen-zod-ts7056-fix

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Stacked on #1902. Closes the final compile gap — `build:lib` now produces `dist/` cleanly. With this merged, the 8.0-beta foundation compiles end-to-end (no `tsc --noEmit` errors AND no `build:lib` errors).

Problem

AdCP 3.1.0-beta.2's schema complexity pushed four more generated Zod schemas past TypeScript's `.d.ts` serialization limit (TS7056). The post-processor in `scripts/generate-zod-from-ts.ts` already handled this for `AdCPAsyncResponseDataSchema` and `MCPWebhookPayloadSchema` by appending a bare `z.ZodType` annotation — but bare `z.ZodType` makes `z.input` resolve to `unknown`, breaking `AdcpToolMap[K]['params']` narrowing.

Solution

`TS7056_SCHEMAS` entries now carry an optional `tsType` field. When present, the annotation uses the 2-type-param Zod v4 form: `z.ZodType<T, T>` with `& Record<string, unknown>` widening to reflect the runtime `.passthrough()` behavior. `z.input` resolves correctly; downstream destructures keep their field types.

Newly annotated:

  • `PreviewCreativeRequestSchema`
  • `UpdateMediaBuyRequestSchema`
  • `UpdateMediaBuyResponseSchema`
  • `BuildCreativeResponseSchema`
  • `SyncEventSourcesResponseSchema`

Auto-injected: `import type { ... } from './tools.generated'` for the typed schemas.

One-line cast at the `withOptionalAccount(UpdateMediaBuyRequestSchema)` call site so the framework helper's `z.ZodObject<...>` constraint is satisfied — runtime shape unchanged.

Verification

  • `tsc --noEmit --project tsconfig.lib.json` → 0 errors
  • `npm run build:lib` → succeeds, dist .d.ts emitted cleanly
  • All schemas in the TS7056 list correctly annotated; post-processor still fails-fast on missing schemas (the original guard).

Adopter migration

None — purely codegen-tooling. The runtime schemas are identical; only the static `.d.ts` annotations changed.

Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]

… schemas

3.1.0-beta.2 pushed four more generated Zod schemas past TypeScript's
.d.ts serialization limit (TS7056). The existing post-processor handled
two pre-3.1 offenders via z.ZodType; extend the mechanism with
optional typed-shape annotations so the new offenders get correct
narrowing instead of falling back to `unknown`.

Changes:
- TS7056_SCHEMAS gains an optional tsType per entry; annotation
  becomes z.ZodType<T, T> (Zod v4 two-type-param form) so
  z.input<typeof X> resolves to the typed shape. & Record<string, unknown>
  reflects runtime passthrough so callers expecting record-shaped
  params keep narrowing.
- Auto-inject `import type { ... } from './tools.generated'` for the
  typed schemas.
- Newly annotated: PreviewCreativeRequestSchema, UpdateMediaBuyRequestSchema,
  UpdateMediaBuyResponseSchema, BuildCreativeResponseSchema,
  SyncEventSourcesResponseSchema.
- One-line cast at the withOptionalAccount(UpdateMediaBuyRequestSchema)
  call site to satisfy the helper's z.ZodObject<...> constraint;
  runtime shape unchanged.

Result: build:lib produces dist .d.ts cleanly. The whole 8.0-beta
foundation now compiles end-to-end.

Part of the #1902 8.0-beta sweep.
@bokelley

Copy link
Copy Markdown
Contributor Author

Superseded by #1924 — the codegen-tooling fix is foundation-neutral, so landing it directly on main is cleaner. The 8.0-beta foundation (#1902) will inherit it on next rebase.

@bokelley bokelley closed this May 22, 2026
@bokelley

Copy link
Copy Markdown
Contributor Author

Acknowledged — noting that this PR is superseded by #1924, with the codegen-tooling fix landing directly on main and #1902 inheriting it on next rebase. No further action needed here.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant