ReviewOS

home-lang/home

fix(ts): preserve generic collection types across checked-JavaScript imports

#957
Closed glennmichael123 opened this 7 days ago ·
7 days ago

Parent: #846

Reproduction: packages/ts_cli/testdata/issue846-whole-export-shapes/ with allowJs, checkJs, strict, noEmit, and esModuleInterop. TypeScript 5.7.3 reports TS2345 at main.ts(11,21) for values.set("ready", "wrong") after importing module.exports = new Map([["ready", 1]]). Home omits that importer diagnostic, although it reports the same TS2345 for a wrong set call inside the exporting map.js. The other string, array, and JSDoc-function controls match TypeScript.

Cause: the owner checker retains the Map type and its two generic arguments, but the checked type schema projected the structural collection to unsupported. The imported file therefore loses the source-owned generic instantiation.

Acceptance: transfer canonical Map/ReadonlyMap/Set/ReadonlySet/WeakMap/WeakSet identities and source-owned arguments without relying on diagnostic display text; reconstruct each in the consumer checker. Verify the exact TypeScript/Home CLI diagnostic streams, serial and parallel Program compilation, and guarded relevant tests. No test weakening or unverified closure.

7 days ago

Baseline expansion (TypeScript 5.7.3): with checkJs enabled, the fixture emits seven diagnostics; with allowJs enabled but checkJs disabled, it emits the same six consumer diagnostics and suppresses only map.js(2,29). Both exact stdout streams and exit code 2 are now encoded in the local test-tsc-streams fixture. No Home test or push claim yet: the approved Zig run was consumed by the compile-time metadata-transfer error, which has been corrected locally but not rerun.

7 days ago

Progress on main: 684475989, 518846515, 4e52ca5, 19df88c, a706bdd. Canonical checked Map<string, number> arguments now transfer across the CommonJS whole-export boundary and the TS consumer reports the TypeScript 5.7.3 TS2345. A Program regression checks serial/parallel compilation and both root orders; exact CLI streams for checkJs true/false pass. Guarded full Program (438/438), checker, and test-tsc-streams passed, with no run above 2,387 MB peak tree footprint. Keeping this issue OPEN: ReadonlyMap/Set/ReadonlySet/WeakMap/WeakSet are not yet admitted by the shared declaration-schema supported-type list. Widening Set prematurely exposed a qualified indexed-type regression (spurious TS2339/TS7006), so those identities still need a sound transfer and consumer implementation, not a test adjustment.

7 days ago

Progress on main: 28bd45d preserves canonical Map/ReadonlyMap/Set/ReadonlySet/WeakMap/WeakSet checked-JS export identities and arguments through CommonJS and ESM; 77e6ca8, 51d2409, and dce9497 add TypeScript 5.7.3 fixtures and exact CLI stream assertions. All four combinations (CommonJS/ESM × checkJs on/off) now produce the same six diagnostics as tsc. Guarded home-tsc build, test-tsc-streams, and full ts_program suite passed under 3,840 MB. Full checker suite is still running. Remaining before closure: broad declaration-schema promotion of the five non-Map names, the qualified indexed-type regression that promotion exposed, and an independent in-memory Program TS2307 on explicit virtual .js imports (the on-disk CLI fixture has no TS2307). No claim of full parity yet.

7 days ago

Verification update: full ts_checker suite also passed under the 3,840 MB guard (peak tree footprint 2,299 MB; host low-water 25%). A controlled attempt to promote Set and the other four non-Map collection names in program_schema reproduced the qualified-indexed regression: TS2339 on mime.map and TS7006 on its callback. Schema tracing showed PartialBag, Base, Internals and FileSchema all marked supported, with qualified routes projection_only=false; allowing builtin_reference in qualifiedDeclarationGraphSupported alone did not fix consumer lowering. I reverted that unverified experiment locally; main is clean and remains at dce9497. Next work is the consumer generic/mapped intersection lowering, not a contextual-projection workaround.

7 days ago

Follow-up shipped: 3632932 fixes the separate Program-only admitted-JS import diagnostic. The resolver now passes source_is_admitted through to the checker, which skips the false TS7016 when allowJs is enabled; it does not suppress unadmitted or allowJs-off imports. A strict 16-cell Program regression covers all six collections across CommonJS/ESM, checkJs on/off, serial/parallel, and both source-add orders. Guarded full ts_program and full ts_checker suites pass. The previously noted virtual Program blocker is resolved. The remaining #957 work is broad schema promotion plus the qualified indexed/mapped intersection consumer regression it exposes; no unsupported promotion was pushed.

7 days ago

Completed checked-JavaScript collection transfer on origin/main through 9b48ab0 (#957). Map, ReadonlyMap, Set, ReadonlySet, WeakMap, and WeakSet now retain canonical generic identities and arguments across CommonJS and ESM imports. The five non-Map names are admitted to the Program declaration schema; qualified graphs reconstruct their references instead of treating them as opaque. Fixed the separate destructuring regression: an unknown string index no longer replaces an explicit intersected array property. Exact TypeScript 5.7.3 CLI fixtures match all six consumer diagnostics for CommonJS/ESM with checkJs on/off; the strict 16-cell Program matrix covers serial/parallel and both source-add orders. Guarded validation at 3,840 MB: full Program 441/441, full checker exited 0, test-tsc-streams exited 0, home-tsc build exited 0. Commit was authored by glennmichael123 without coauthors. #846 and #66 remain open for broader work beyond this collection scope.

Sign in to comment on this issue.