ReviewOS

home-lang/home

fix(ts): retain inferred const types across transitive value imports

#936
Closed glennmichael123 opened this 8 days ago ·
8 days ago

Found while qualifying #925 on main cde9c31 (Darwin arm64). A real three-file project has leaf.ts exporting const leafValue: string, middle.ts importing it and exporting const value = leafValue, and main.ts assigning imported value to number. Pinned TypeScript 6.0.3 and native TypeScript 7.0.2 both report exactly TS2322 at main.ts(2,14); the pre-fix production Home binary exited 0. Adding an explicit : string annotation to middle.value makes Home report TS2322, isolating the loss to source-owned initializer type transfer rather than resolution or watch events. The Program regression also reproduced this after an import was introduced during an incremental revision. Source inspection: class_schema.Builder lowered unannotated const initializers through type-expression lowering, where an imported value identifier was unsupported; the exported declaration became projection-only, so consumers saw no concrete value type. Acceptance: preserve the uniquely resolved imported value declaration identity through aliases/barrels and incremental revisions; retain ambiguity, type-only imports and unproductive value cycles as unsupported; match both pinned reference compilers on positive and negative controls; pass affected Program, CLI and production gates under the 3,840 MB guard. Refs #925 and #66. No full watch-mode or full TypeScript parity claim.

8 days ago

Fixed on origin/main in 8325f77 (3 files; author and committer glennmichael123). Source-owned unannotated const initializers now retain a uniquely resolved imported value declaration through aliases and barrels; ambiguity, type-only imports, and unproductive value cycles remain unsupported. On the updated main base: guarded ts_program 354/354, tsc_main 60/60, ts_cli 88/88, and production home-tsc build passed under the 3,840 MB ceiling. A real three-file negative control reports TS2322 at main.ts(2,14) in Home, pinned TypeScript 6.0.3, and native TypeScript 7.0.2; the positive control is accepted by all three. This closes only the transitive imported-const inference gap, not #925 watch-mode parity or #66 full Bun parity.

Sign in to comment on this issue.