ReviewOS

home-lang/home

TypeScript parity: nullish literals and conditional assignment flow

#771
Closed chris opened this 8 days ago ·
8 days ago

Tracks the TypeScript compatibility batch for nullish-coalescing literal precision and reachable conditional-assignment flow, as part of #66 and #548.

Two independent checker gaps affected the pinned Zod project:

  • ?? widened a literal fallback before forming the result union. Optional literal unions such as ("input" | "output" | undefined) ?? "output" therefore became string | "input" | "output" and failed their declared property types. Nullish coalescing now preserves the fallback's fresh literal type while leaving the surrounding context free to widen the completed expression.
  • Function-local if flow only propagated a narrow subset of exhaustive assignments. Nested and partial branches could leave an annotated mutable literal union stuck at its initializer, while an exiting branch was still treated as reachable. Conditional flow now joins every reachable identifier assignment, preserves the incoming type on a missing branch, excludes return/throw/break/continue paths, and keeps contextually accepted constructor assignments on their declared non-nullish collection type.

Implemented in fd4339d.

Validation:

  • Type checker: 4,387/4,387 tests pass in ReleaseFast.
  • Full ReleaseFast build with JSC: 50/50 steps pass.
  • Pinned Zod v4.5.2 core oracle: 30 diagnostics -> 25, removing five expected false positives with zero additions.
  • Official TypeScript 6.0.2 focused oracles agree on literal fallback unions, partial branch joins, and exiting-branch flow.
  • Focused formatting, diff, and Pickier checks pass.
8 days ago

Completed and pushed to main in fd4339d.

The pinned Zod v4.5.2 core oracle drops from 30 to 25 diagnostics with zero additions. ReleaseFast checker tests pass 4,387/4,387 and the full JSC-enabled build passes 50/50 steps.

Sign in to comment on this issue.