ReviewOS

home-lang/home

fix(ts): retain CommonJS function and class export expandos

#965
Closed glennmichael123 opened this 5 days ago ·
5 days ago

Verified differential (TypeScript 5.7.3)

With allowJs, checkJs, strict, noEmit, module: commonjs:

module.exports = function () {};
module.exports.extra = function () {};

TypeScript exits 0 with no diagnostics. The currently built Home CLI emitted TS2339 on module.exports.extra (and the separate spurious TS2309 tracked in #964). The analogous class export with a later module.exports.T write also exits 0 in TypeScript, while Home emitted TS2339. This is a distinct expando-shape problem: removing TS2309 alone does not type the later property.

Acceptance

  • Model later module.exports.name writes as static/expando members of an exported function or class where TypeScript does, and expose them to importers.
  • Preserve genuine TS2339 for writes to non-extensible/closed values and respect declared property types.
  • Add exact owner and importer TypeScript 5.7.3 CLI controls, Program/checker tests, and guarded sequential suite verification.
  • Do not suppress TS2339 without representing the member in the exported type.

Related: #846, #964, #66.

4 days ago

Checkpoint on origin/main (13 glenn-authored commits 7ae079387..ee22b4f60, no coauthors): inferred CommonJS function/object/class whole exports now retain later module.exports.name and exports.name members in admitted importers; explicit JSDoc whole types stay closed. --checkJs false retains fresh literal write constraints. Exact TypeScript 5.7.3 auditor: 118/118 stdout/stderr/exit streams (113 configs + five unchecked overrides). Guarded direct checker: 4,713/4,713. Full ts_program and test-tsc-streams steps passed; focused Program edit/remove/revert test passed in both checkJs modes. The LSP edit/revert regression is committed in ee22b4f60 and passes Zig syntax check, but its test target was stopped twice by the authorized 3,840 MB tree guard (3,845 and 3,869 MB); it has not been executed. Keeping #965 open until that verification is resolved. Distinct remaining gaps: #966 constructor contextual this, #967 repeated whole-export unions. Related #846 and #66.

4 days ago

The outstanding LSP verification is now complete. With 51% host memory free at admission, the dedicated guarded command

HOME_RUN_MAX_MB=3840 HOME_RUN_MIN_LEVEL=40 HOME_RUN_CRIT_LEVEL=15 perl scripts/run-bounded.pl 600 zig build test-ts-lsp -Dts-lsp-test-filter='CommonJS expando edits republish importer diagnostics' -j1

exited 0; peak tree footprint was 1,968 MB and host low-water was 39%. The test exercises an admitted JavaScript whole-function export with a later .extra write, removes that write, restores it, and verifies importer LSP diagnostics in both checkJs modes. The earlier exact TypeScript 5.7.3 owner/importer controls, direct checker 4,713/4,713, full Program and CLI stream steps, and Program edit/remove/revert coverage are recorded above. The follow-on repeated whole-export union work is complete in #967. The distinct constructor/contextual this gap remains open in #966. #846 and #66 retain the broader scope.

5 days ago

Additional exact TypeScript 5.7.3 controls: an anonymous function whole export plus module.exports.extra = () => 1 and a TS import = require reader exits 0 in tsc, but Home emits TS2339 in both owner and importer. A class whole export plus module.exports.extra = 1 exits 0 in tsc; Home emits TS2339 only in the owner (the importer already sees the static member). Crucial negative control: /** @type */ module.exports = {count:1}; module.exports.extra = 2 emits the same TS2339 in both tsc and Home. Therefore this needs open inferred function/class expando semantics, not blanket removal of TS2339. The controls were run through the 1,024 MB guard; no implementation for this issue has landed yet.

Sign in to comment on this issue.