This repository was archived by the owner on Nov 4, 2026. It is now read-only.
Repository navigation
Commit 0f99492
committed
test(types): teach the WiderThanDeclared operator to see an open-record mirror
`zod-mirror-parity.test.ts` decided the WIDER direction with one assignability
test, and that test cannot separate `Record[string, V]` from
`Partial[Record[UNION, V]]` in EITHER direction — the two are mutually assignable,
because TypeScript grants an implicit index signature to mapped and anonymous
object types. So a mirror spelled `z.record(z.string(), V)` read as clean against a
declaration over a finite key union while genuinely accepting keys the declaration
refuses, and both parity directions agreed it was clean (objectui#8517).
The repair adds an OPEN-RECORD clause on the branch the assignability test already
called clean, so it is additive by construction: a key reported before cannot stop
being reported. It reports only the unambiguous case — the mirror has a union arm
that is a string-index record with no literal members of its own (the
`z.record(z.string(), V)` shape and nothing else), and the declaration has a
finite-keyed arm and no open one.
Two halves of the predicate were MEASURED rather than reasoned about, each after
the pin written for it failed. A zod LOOSE object also answers `true` to
`string extends keyof T`, so requiring no literal members is what keeps the whole
passthrough population out; and `keyof number` resolves to that primitive's method
names, so `FiniteKeyedArms` has to exclude non-objects or a permissive
`number | object` declaration reads as narrow.
Census delta, measured with the file's own ledger reconciliation: 2 pairs and 2
keys ENTER, none leave. `layout.zod.ts#GridSchema::columns` (objectui#8516's
instance) and `reports.zod.ts#ReportComponentSchema::exportConfigs`, which was not
known to exist. Both are demonstrated at runtime as accept-set gaps — `safeParse`
green, `tsc` refusing the same document — so neither can be read as an artifact of
the new clause.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YBWFb5YgMU5dw8p2VKj16S1 parent 3f775ee commit 0f99492
2 files changed
Lines changed: 404 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
0 commit comments