ReviewOS

home-lang/home

fix(ts): type imported values whose declared type cannot be transferred

#763
Closed glennmichael123 opened this 9 days ago ·
9 days ago

Parent: #758 · Related: #548, #754

core/api.ts:1732 and :1745 report a false TS7006 on inst in

const ch = new checks.$ZodCheck({ check: "describe" });
ch._zod.onattach = [ (inst) => { ... } ];

The array literal and the assignment are not at fault: Home types the imported value checks.$ZodCheck as any, and TypeScript reports TS7006 for a callback contextually typed by any too (verified against tsgo). The value export is dropped in packages/ts_program/src/declaration_graph.zig (if (!entry.value_ptr.*) continue;): a value whose declared type is unsupported is not published at all, while type-space exports are published with projection_only = true. $ZodCheck's graph reaches leaves program_schema.zig rejects (Set<string>, Record<string, unknown>, typeof version, a this-typed "~standard" member, and self-cycles), so checks.$ZodCheck becomes any, new gives any, and _zod.onattach is any.

Publishing unsupported value exports as projection-only would fix it, but that is the approach measured and rejected in #754 (+38 identities: 30 TS7006 in core/compile.ts, plus TS2322/TS2345/TS2559), and it would reach all 104 core.$constructor<...> exports. A context-only variant along the lines of #751/#754 — lowering the projection solely where a member is read or a contextual type is needed, leaving the receiver any — is the direction worth measuring. Any candidate must be A/B-gated on the unchanged Zod core shard before landing.

9 days ago

Completed in cdad20fe5d and pushed to origin/main.

Unsupported value exports are now retained as projection-only declaration metadata. Ordinary import reads still resolve to any; only contextual assignment discovery may follow an unannotated local back through a projection-only imported constructor and project the exact requested member chain. For Zod this traces new checks.$ZodCheck(...) to _zod.onattach and types the callback while keeping the constructor, instance, and assignment target out of normal relation checks. Parse-diagnostic files retain their previous closed-literal-only recovery boundary.

Acceptance evidence:

  • Full checker: 4,379/4,379
  • Full Program: 217/217
  • ReleaseSafe home-tsc: passed
  • Exact Zod v4.5.2 core: 45 → 43 diagnostics, removing only api.ts:1732:6 TS7006 and api.ts:1745:6 TS7006, with zero additions
  • TypeScript 6.0.2 oracle: TypeScript and Home both report the same deliberate api.ts:5:11 TS2322 and no TS7006
  • Focused Pickier, zig fmt --check, and git diff --check: passed

The broader value remains intentionally permissive rather than publishing the previously rejected approximation that added 38 Zod diagnostics. This issue's contextual member-projection scope is complete.

Sign in to comment on this issue.