ReviewOS

home-lang/home

fix(ts): preserve contextual methods on partially transferable imported classes

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

Parent: #548

A strict two-file reduction shows that an imported class method loses contextual callback parameter types when an unrelated class member makes the complete class schema unsupported. TypeScript 6.0.3 and the native TypeScript preview report zero diagnostics; ReleaseFast Home reports TS7006 for both the direct and nested callback parameters.

The production symptom is the repeated doc.indented callback family in the pinned Zod 4.5.2 corpus. The general defect is all-or-nothing imported-class transfer: the fallback preserves member names but degrades method types to any even when the individual method contract is transferable.

Acceptance criteria:

  • preserve transferable imported class method signatures when sibling members are unsupported
  • retain recursive self types so nested method callbacks remain contextually typed
  • do not broadly admit unsupported class graphs or add corpus diagnostics
  • add positive and negative multi-file regressions
  • match TypeScript 6.0.3 and the native preview on a fair standalone oracle
  • require full checker and Program suites, ReleaseFast, and an exact unchanged-corpus diagnostic diff
  • publish the result in the performance record and README
8 days ago

Completed on main in 9fe50f3 and documented in a903452: https://github.com/home-lang/home/blob/main/docs/docs/TS_PERFORMANCE.md#partially-transferable-imported-class-methods

The projection-only design preserves the established whole-class fallback and lowers only requested callable members, including exact recursive self receivers. The fair two-file oracle matches TypeScript 6.0.3 and the native preview exactly: no TS7006 for direct or nested callbacks, plus TS2339 and TS2322 negative controls. The unchanged Zod 4.5.2 graph completes twice with byte-identical output (SHA-256 3212f2598cc37ba0eb8a98a14c0ddfe82158ee4797ee75ec8f5d8565d5414774), moving 430/425 to 400/395 diagnostics/unique identities: 30 TS7006 removals and 0 additions. The initial whole-class candidate crashed the corpus and was rejected without a commit. Full checker and 190/190 Program tests plus ReleaseFast pass. Closing as completed.

Sign in to comment on this issue.