Skip to content

test: sweep the redundant producer casts, keep one as the back-compat net - #52

Merged
btravers merged 2 commits into
mainfrom
followup/spec-cast-sweep
Aug 9, 2026
Merged

test: sweep the redundant producer casts, keep one as the back-compat net#52
btravers merged 2 commits into
mainfrom
followup/spec-cast-sweep

Conversation

@btravers

@btravers btravers commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #50, which retyped computed's from and factory generators as their schema's z.input and swept docs and examples. The package's own test files were left for follow-up — they held the only as z.infer casts remaining in the repo, and they contradicted the documented "producers need nothing" story.

The rule applied

Delete iff producer position; everything else stays:

kept why
update(...) patch casts PatchOf is deliberately branded — those casts are still required
as never casts deliberate wrong-value smuggling; documented in-file
Entity.Input/CreateInput/Patch helper-type literals those types are z.infer-based (branded) and unaffected by #50
readonly-array and brand-nominality probes they test the brands themselves
the Legacy guard see below

15 producer casts deleted across 6 files. 19 casts survive, each classified.

The one deliberate producer cast left in the repo

entity.test-d.ts's Legacy guard — a computed from returning as z.infer<typeof Upper> — is relabelled as the designated back-compat net: it pins that pre-#50 cast-carrying code still compiles (a branded return assigns to its schema's input). Its comment now says exactly that, so no future sweep takes it.

Review also caught a title made stale by the sweep: "computed's function … must return brands" sat above a castless return "X". Retitled to what the test now pins.

Test plan

  • Review re-derived every deletion as a genuine producer position against computed.ts/types.ts's signatures, and classified all 19 survivors
  • Package test / typecheck / test:types (no @ts-expect-error went unused), lint, format --check — green
  • Full repo typecheck / test / knip — green

No changeset — test-internal.

🤖 Generated with Claude Code

… net

PR #50 retyped computed's `from` callback and factory generators to the
schema's `z.input`, making the `as z.infer<typeof X>` casts on their
return values redundant. Sweeps them from the package's own spec and
test-d files (docs and examples were already swept), leaving update()
patch casts (PatchOf stays branded) and the one deliberate Legacy cast
kept as a back-compat pin.
…ss return

Review flagged the old title as inaccurate after the cast sweep: the
test's own final line (a castless return) demonstrates the opposite
of "must return brands".
Copilot AI lite review requested due to automatic review settings August 9, 2026 12:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR follows up on #50 by removing now-redundant as z.infer<...> casts that were only needed when producer callbacks (computed from functions and factory generators) were typed as branded outputs rather than schema inputs. It updates the package’s own spec/type-test files to match the new “producers need nothing” story while keeping a single intentional cast as a back-compat guard.

Changes:

  • Removed producer-position as z.infer<...> casts from computed field derivations across spec and type-test files.
  • Updated the type-test case name and body to reflect that computed return values are validated as schema input (no brand required).
  • Kept one explicit producer cast in entity.test-d.ts (Legacy) as the designated back-compat net.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/entity/src/nesting.spec.ts Removes the redundant cast from a nested entity computed field derivation.
packages/entity/src/entity.test-d.ts Sweeps producer casts, updates the computed typing test title/body, and preserves the single Legacy cast as back-compat coverage.
packages/entity/src/contract.spec.ts Removes the redundant cast from a contract example’s computed field.
packages/entity/src/computed.spec.ts Removes redundant casts from multiple computed derivations, including defect-path tests.
packages/entity/src/base.test-d.ts Removes redundant casts from computed derivations in abstract-root/variant type tests.
packages/entity/src/base.spec.ts Removes redundant casts from computed derivations in root/extend runtime specs.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@btravers
btravers merged commit 1bbc86e into main Aug 9, 2026
14 checks passed
@btravers
btravers deleted the followup/spec-cast-sweep branch August 9, 2026 12:54
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.

2 participants