ReviewOS

home-lang/home

fix(ts): preserve mapped prototype parameter tuples

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

Parent tracking

Evidence

After #619, the unchanged pinned 106-file Zod 4.5.2 graph has 976 Home diagnostics. TS7006 remains the largest class at 368; 251 are in src/v4/classic/schemas.ts.

A strict four-file NodeNext reduction uses the same imported ProtoOf<T> pattern:

type ProtoOf<T> = {
  [K in keyof T]?:
    (T[K] extends (...args: infer A) => infer R ? (...args: A) => R : T[K])
    | undefined;
} & ThisType<T>;

The target interface contains:

  • a method with optional parameters;
  • a generic method with a constrained type parameter;
  • a rest parameter whose element is a callable/object union;
  • a generic callback parameter;
  • an invalid def?.missing control.

Pinned TypeScript 6.0.3 and native TypeScript 7.0.2 report only the deliberate TS2339 at the same location. Current Home adds seven TS7006 diagnostics plus one TS7019, and misses TS2339 because the optional parameter is contextually reduced to any.

This is not Zod-specific: conditional mapped-member inference preserves simple and overload-selected signatures after #619, but does not yet preserve optional, rest, and generic parameter tuples.

Acceptance gates

  • Make the reduced valid methods free of TS7006/TS7019.
  • Restore the deliberate TS2339 with the same code and location as TypeScript 6 and 7.
  • Preserve generic constraints, optionality, rest element types, return types, and polymorphic this without whole-type approximation or source-name special cases.
  • Add local and imported/barrel Program coverage, including negative assignment/property controls and lexical shadowing.
  • Run Program and checker suites, Zig formatting, scoped Pickier, and git diff --check.
  • Compare normalized diagnostic identities on the exact same pinned Zod graph against the exact parent; require zero additions before documenting any removal.
  • Measure ReleaseFast only as a same-correctness Home A/B. Do not add Zod to the cross-compiler timing table until Home reaches the TypeScript zero-diagnostic oracle.
  • Document accepted results in docs/docs/TS_PERFORMANCE.md and the concise linked README table.

Non-goals

  • No diagnostic suppression.
  • No Zod, method-name, or source-spelling special cases.
  • No approximate publication of an imported interface graph.
  • No benchmark filtering or discarded samples.
8 days ago

Implemented and validated the mapped prototype parameter tuple/contextual receiver work in small issue-linked commits.

Semantic result:

  • Exact parent: ad4ae6291
  • Final semantic candidate: babca3e64
  • Pinned input: Zod 4.5.2, 106 production TypeScript files, unchanged tsconfig.benchmark.json
  • Diagnostics: 976 -> 833 (143 removed, 14.7%; 0 normalized additions)
  • Removed codes: 127x TS7006 and 16x TS7019
  • Raw output hashes: parent 6a84880a00f1e22816610e546a964e5e5ce88e78b2e1baefcc9c7c461a699c8a, candidate 94ecd8b025e5248c1ab3f84d32ae560eaabf3119c5e7e844c654fbe0f740b6d5
  • Normalized key hashes: parent c3effc18a013210ee3f0129e6f4aa10e609d6dedf9276c4e9f2cc52ac921fc7b, candidate 6bbfaf9ca1acef7e056c09def0d162daab7fd918f324deaadecf11eed9f331b3
  • Pinned TypeScript 5.9.2 accepts the valid classic-schema probe and rejects the invalid controls.

Validation:

  • Program: 174/174
  • Checker: 4,334/4,334
  • ReleaseFast home-tsc build
  • zig fmt --check on all six changed Zig files
  • Scoped bunx --bun pickier README.md docs/docs/TS_PERFORMANCE.md
  • git diff --check

Performance evidence:

  • The semantic parent/candidate transparency medians are 4.38 s and 5.14 s (+17.4%). This is not admitted as a speed comparison because the candidate performs more complete checking.
  • A same-correctness performance-only reorder produced byte-identical 833-diagnostic output. Ten counterbalanced AB/BA pairs measured 5.26 s before and 5.36 s after, with the reorder winning 3/10 pairs. I rejected and removed that probe instead of shipping a measured slowdown.

Documentation is in ef30397a4, including the brief README table and the detailed TS_PERFORMANCE.md section. I am rebasing and will post the final pushed main commit range after the integration gates pass.

8 days ago

Landed on main as b73c3a20a..4deb785cc.

Final integration verification after the last rebase:

  • Program 174/174
  • Checker 4,334/4,334
  • ReleaseFast home-tsc
  • Pinned Zod 4.5.2 audit: 833 diagnostics, byte-identical to the frozen candidate (94ecd8b025e5248c1ab3f84d32ae560eaabf3119c5e7e844c654fbe0f740b6d5)
  • 143 diagnostics removed from the exact parent, with 0 normalized additions
  • origin/main verified at 4deb785ccef31bdaedceb5adc72db7bcb67a7839
  • All 11 commits are authored by Chris Breuer and contain no coauthor trailers

The brief result table is in the README and the full methodology, hashes, timing transparency, and rejected same-correctness performance probe are in docs/docs/TS_PERFORMANCE.md.

Sign in to comment on this issue.