ReviewOS

home-lang/home

fix(ts): retain admitted CommonJS whole-export type on default imports

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

Reproducer

A checked JavaScript source with module.exports = 42 is imported as a default by a TypeScript consumer that assigns it to string. TypeScript 5.7.3 reports TS2322 at the consumer assignment. Before the fix, Home emitted no diagnostic for both a relative source and a real node_modules package admitted by maxNodeModuleJsDepth: 1.

At the default package depth of 0, both compilers correctly report only TS7016 for the unadmitted package. --listFiles confirms the package JS enters Home’s Program at depth 1.

Root cause and acceptance

The checker’s default-import binding path used the source-owned named CommonJS export object, then a bare-package any fallback, but omitted the already-collected whole module.exports schema. Read that schema first for admitted owners; preserve TS7016 for unadmitted packages. Lock exact TypeScript CLI streams/exits for depth 0, depth 1, and a relative import, plus serial/parallel Program tests. Run guarded suites and push to main under the user identity. Parent: #846.

7 days ago

Resolved on origin/main in 9a39333 (untyped package oracle), 24dcc34 (admitted/relative controls), and 8864f15 (whole-export default-import typing and exact regression assertions). The checker now reads the admitted Program-owned module.exports schema before its named-export/any fallback. TypeScript 5.7.3 and freshly rebuilt Home agree on exact output and exit code for: default depth TS7016 (absolute package path and remediation hint), depth-1 admitted package TS2322 (number to string), and relative admitted source TS2322. zig build test-tsc-streams, focused serial/parallel Program regression, full Program target, tsc_main, fresh home-tsc build, zig fmt --check, and diff hygiene exited 0 under the 3,840 MB serial guard. The full checker target also exited 0 but printed its pre-existing anomalous failed command line, so that run is not represented as an unqualified clean pass. Peak measured tree footprints: Program 2,432 MB, checker 2,365 MB, tsc_main 2,096 MB. #846 remains open for its broader acceptance.

Sign in to comment on this issue.