ReviewOS

home-lang/home

fix(ts): contextually type member-assigned callbacks

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

Parent: #548 Tracker: #416

Problem

Home checks a function expression on the right of an element assignment with the resolved target signature before its body, but an ordinary member assignment currently checks the function expression without that context. On pinned Zod 4.5.2 this leaves all three parameters of each inst._zod.processJSONSchema = (ctx, json, params) => ... arrow implicit any: 41 assignments account for 123 of the remaining 241 TS7006 diagnostics.

The receiver is generic (T extends Trait) and the callable property is nested and optional, so this must be fixed through normal target/member/type-parameter resolution rather than source spelling.

Acceptance

  • Contextually type a member-assignment function expression when the resolved write target has one unambiguous callable parameter signature, matching the existing element-assignment rule.
  • Preserve parameter types through a generic constrained receiver and a nested member access.
  • Handle an optional callable property without choosing an incompatible union signature.
  • Keep strict negative controls for unknown parameter properties and an invalid callback return type, with TypeScript-matching diagnostic codes.
  • Keep ambiguous callable unions and incompatible overload parameter lists conservative.
  • Do not inspect Zod paths, identifiers, method names, or source text, and do not suppress diagnostics after an untyped check.
  • On the unchanged pinned 106-file Zod 4.5.2 graph, remove the 123 processJSONSchema TS7006 diagnostics with zero added normalized diagnostics.
  • Pass the focused reduction, Program and Checker suites, ReleaseFast, Zig formatting, scoped Pickier, and git diff --check.
  • Record exact diagnostic and fair benchmark evidence in TS_PERFORMANCE.md, add a brief linked README table update, and keep this issue and both parents current.
8 days ago

Implemented and pushed directly to main in 5d52836, d846dbe, and 2de0edb.

Final pinned Zod 4.5.2 ReleaseFast audit against exact parent 4deb785:

  • all diagnostics: 833 -> 710 (-123, 14.8%)
  • TS7006: 241 -> 118 (-123, 51.0%)
  • normalized additions: 0
  • all removals are the three parameters on the 41 selected processJSONSchema assignments

Validation:

  • checker suite passed
  • Program 175/175 passed
  • ReleaseSafe and ReleaseFast home-tsc passed
  • TypeScript 6.0.3 and native TypeScript 7.0.2 oracle controls match
  • zig fmt, scoped Pickier, and git diff --check passed

The implementation uses generic call-site provenance and isolated Program-schema member projection, keeps ambiguous/free/non-void projections conservative, and contains no Zod path/name/source-text special case. README and detailed evidence are linked in the docs commit.

Sign in to comment on this issue.