ReviewOS

home-lang/home

fix(ts): preserve JSDoc CommonJS exports and permit property augmentation

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

TypeScript 5.7.3 differential

In an admitted JavaScript owner, /** @type {Payload} */ module.exports = { count: 1, label: 'ready' } with Payload = { readonly count: number, label?: string } must publish the declared type to TypeScript importers even when checkJs is false. Home published only the inferred object literal type, losing readonly and optionality in the importer.

TypeScript also accepts module.exports = { count: 1 }; module.exports.count = 2; and the analogous later exports.count = 2. Home incorrectly emitted TS2309, which is for conflicting TypeScript export = declarations, not ordinary CommonJS augmentation.

Acceptance

  • Preserve the source owner's JSDoc declaration through the checked Program schema in both checkJs modes, without adding owner diagnostics when checkJs is off.
  • Keep the real export = exclusivity and declaration-emit rules.
  • Add exact TypeScript 5.7.3 CLI stream fixtures and checker/Program regressions; run guarded sequential Zig suites.
  • Record any additional CommonJS expando gaps separately rather than suppressing their diagnostics blindly.

Parent: #846. Broader parity: #66.

5 days ago

Implemented and pushed to origin/main in 962dacb, 59620e9, b6bdd86, d903104, and 2923854. The owner-scoped checked schema now retains a leading module.exports JSDoc @type in both checkJs modes, including readonly and optional fields. JavaScript whole-export plus property writes no longer emit spurious TS2309; real TypeScript export = conflicts remain checked. Verification: TypeScript 5.7.3 CLI auditor 106/106 exact stdout/stderr/exit; direct guarded checker executable 4,713/4,713; focused Program two-mode regression and test-tsc-streams passed. The Zig build wrapper's checker status was ambiguous, so the direct executable count is the authoritative result. Separate function/class expando TS2339 remains open in #965.

5 days ago

Follow-up c45249e is also on origin/main: the seven new config streams are now pinned in zig build test-tsc-streams, the #846 auditor checks the checked schema/transfer sources for stale binaries, and the TypeScript parity documentation records the 106/106 checkpoint plus #965 scope. Guarded test-tsc-streams passed; independent TypeScript 5.7.3 auditor remains 106/106 exact. Full guarded Program suite also passed after the implementation batch.

Sign in to comment on this issue.