ReviewOS

home-lang/home

fix(ts): resolve default-lib aliases in nested type arguments

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

Problem

Home resolves the default-lib alias PropertyKey when used directly, but its generic type-argument unresolved-name sweep independently reports TS2304 for the same alias inside Record<PropertyKey, unknown>. TypeScript 6.0.3 and native TypeScript 7.0.2 accept both forms.

The current pinned Zod 4.5.2 candidate contains four such TS2304 diagnostics: src/v4/core/schemas.ts:3118 and src/v4/core/util.ts:160/400/424.

Fair oracle

A fresh strict, no-emit project contains direct PropertyKey, Record<PropertyKey, unknown>, an interface member, a function parameter/return, and a value annotation. Its negative counterpart only adds Record<MissingKey, unknown>.

  • Valid: TS 6.0.3 = 0, TS 7.0.2 = 0, Home currently = one false TS2304 on nested PropertyKey.
  • Negative: TS 6.0.3 and TS 7.0.2 each retain exactly one TS2304 on MissingKey; Home currently emits that plus the false PropertyKey diagnostic.

Oracle: /tmp/home-ts-property-key.

Acceptance

  • Reuse normal default-lib type-name resolution in parsed generic arguments; do not special-case Zod, Record, a source location, or suppress TS2304 broadly.
  • Keep an unresolved non-lib name such as MissingKey diagnostic.
  • Add a permanent positive/negative regression.
  • Run focused and full checker suites, Program integration, ReleaseFast, formatting, diff checks, and scoped Pickier.
  • Compare complete pinned Zod diagnostic identities against #660 and the immutable #548 baseline; zero candidate-only identities required.
  • Publish the exact audit in docs/docs/TS_PERFORMANCE.md and the linked compact README table under #416.
8 days ago

Implementation and validation evidence

Root cause

  • reportUnresolvedCallTypeArgumentNodes maintained a separate name-resolution predicate for parsed generic arguments.
  • That predicate checked primitives, values, builtins, imports, visible declarations, and known generic roots, but omitted the checker existing default-lib type-only registry.
  • The ordinary lowerer already resolves PropertyKey to string | number | symbol; the pre-lowering sweep emitted the false TS2304 first.

General fix

  • Parsed generic arguments now consult isDefaultLibTypeOnlyFallbackName, the same registry used by normal annotation resolution.
  • No Zod, Record, PropertyKey, file, or diagnostic location is special-cased in the new rule.

Fair oracle: /tmp/home-ts-property-key

  • Valid direct and nested default-lib aliases: Home ReleaseFast 0; TypeScript 6.0.3 0; TypeScript 7.0.2 0.
  • Negative Record<MissingKey, unknown>: all three retain exactly one TS2304 on MissingKey.

Pinned Zod 4.5.2

  • Parent #660: 440 diagnostics / 435 unique file:line:column:code identities.
  • Candidate: 436 diagnostics / 431 unique identities.
  • Delta: exactly four TS2304 removals, zero additions.
  • Removed: src/v4/core/schemas.ts:3118:73 and src/v4/core/util.ts:160:33, 400:53, 424:52.
  • Immutable #548 baseline: 602 diagnostics / 597 unique identities. Candidate is 166 unique removals with zero additions.
  • Candidate distribution begins TS2345 203, TS7006 100, TS2339 59, TS1361 16, TS2304 12, TS2322 12; every remaining code is below five.

Regression and validation

  • Permanent positive/negative checker regression: pass.
  • Full ts_checker: pass (4357/4357).
  • ts_program: pass (189/189).
  • ReleaseFast: pass; wall time excluded because the host was contended.
  • zig fmt --check, git diff --check, scoped Pickier: pass.

Evidence

  • /tmp/home-zod-661-candidate.stderr
  • /tmp/home-zod-661-candidate-keys.sorted
  • /tmp/home-zod-660-candidate-keys.sorted
  • /tmp/home-zod-548-current.stderr
8 days ago

Completed on main.

The valid and negative TS6/TS7/Home controls agree exactly, the permanent and broad regressions pass, and pinned Zod removes exactly four TS2304 identities with zero additions. Closing this scoped issue; #548 and #416 continue.

Sign in to comment on this issue.