ReviewOS

home-lang/home

fix(ts): honor real package format in Node ESM diagnostics

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

Found during #925 watch verification on main e7a0b31 (Darwin arm64). These are separate static-checking gaps, not a failure of the package metadata watcher. Reference is local TypeScript 5.7.3; the freshly rebuilt Home binary was tested with the same source and options plus its --ignoreConfig flag.

Case A: package.json is {"type":"commonjs"}; main.ts is export const answer = 42;. With --noEmit --strict --skipLibCheck --module nodenext --moduleResolution nodenext --verbatimModuleSyntax --pretty false, TypeScript exits 2 with TS1287 at (1,1). Home exits 0 with no diagnostic.

Case B: the same package.json; dep.mts is export const answer = 42;, and main.ts imports { answer } from "./dep.mjs" then exports result = answer. With --noEmit --strict --skipLibCheck --module node16 --moduleResolution node16 --pretty false, TypeScript exits 2 with TS1479 at (1,24) and the ESM conversion hint. Home exits 0 with no diagnostic.

The checker already has package-format-aware helpers and virtual-section tests, but those do not prove these real-file CLI cases. Determine the actual cause of each missing diagnostic; add positive ESM-package controls and complete real-file regressions. Preserve TypeScript semantics rather than special-casing these filenames or suppressing diagnostics. Verify the affected checker, Program, and CLI suites. Refs #66 and #925.

8 days ago

Implemented and pushed cde9c31 directly to main. Root causes: the CLI silently ignored --verbatimModuleSyntax, the driver did not carry its override into checker flags, and the checker only resolved relative imports from virtual conformance sections rather than real files. Added a Program regression that verifies TS1295/TS1479/TS1287 for a CommonJS package and verifies all three disappear after changing the package to ESM. Pinned TS 6.0.3 and TS 7.0.2 (rather than the TS 5.7.3 initially cited here) both produce those three codes at main.ts(1,10), (1,24), and (2,1) under Node16; Home now matches. NodeNext produces TS1295/TS1287 without TS1479, also matching. Focused suites passed: driver 215/215, Program 335/335, CLI 82/82, checker 4655/4655; production home-tsc built under the 3,840 MB guard. The text of the TS1479 related hint matches, but Home adds a source-location prefix to that secondary line; that display-only difference is outside this diagnostic fix.

Sign in to comment on this issue.