ReviewOS

home-lang/home

fix(ts): retain JSDoc parameter types from unchecked JavaScript exports

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

Parent: #846. Related: #957.

TypeScript 5.7.3 baseline: with allowJs true, checkJs false, strict true, noEmit true, a JavaScript export annotated with /** @param {number} value */ still constrains a TypeScript importer. Both CommonJS default and ESM named imports report TS2345 for increment("wrong"). checkJs only suppresses diagnostics within the JS owner; it does not erase owner type information.

Reproduction: packages/ts_cli/testdata/issue846-whole-export-shapes/tsconfig-no-checkjs.json and tsconfig-named-no-checkjs.json. Before local changes Home missed the CommonJS importer TS2345. The focused checker gate now restores that case and exact CLI streams pass under the 3,840 MB guard, but the ESM named export still silently succeeds (Home exit 0 vs TypeScript exit 2), with a red serial/parallel Program regression.

Cause under investigation: the JavaScript function declaration projector only materializes a JSDoc function signature when an explicit @returns tag is present. A param-only annotation falls back to a syntax-only function type, losing the JSDoc parameter. Fix must preserve the checked owner signature and inferred return without special-casing this fixture; guarded Program, checker, and exact CLI tests required before closure.

7 days ago

Fixed on origin/main in 684475989 and 518846515, with exact TypeScript 5.7.3 fixtures in 4e52ca5, 19df88c, and a706bdd. checkJs now controls JS owner diagnostics without erasing JSDoc parameter types. Parameter-only ESM functions publish their final checked signature after the owner is checked, including the body-inferred return; parallel admission uses dependency batches. The CommonJS and named ESM consumers report TS2345 with checkJs false; the fully checked function case reports the four expected TS2345/TS2322 diagnostics. Guarded full Program 438/438, full checker, and exact CLI streams passed; max observed peak tree footprint 2,387 MB under the 3,840 MB guard. No tests were weakened.

Sign in to comment on this issue.