ReviewOS

home-lang/home

fix(ts): retain admitted-JS default function types across imports

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

Parent: #846.

Fresh TypeScript 5.7.3 real-file control: owner.js exports /** @returns {number} */ export default function answer() { return 42; }; main.ts default-imports it and assigns answer() to string. With --allowJs --noEmit --strict, TypeScript reports one TS2322 at main.ts(2,7), while freshly built Home reports zero diagnostics and exits success. An equivalent named JSDoc-typed function from the same owner correctly produces TS2322 in Home. The same default-route miss occurs for an admitted .jsx owner under --jsx preserve --allowJs; with --jsx unset both compilers report TS6142, and with JSX enabled but allowJs unset both report TS7016. The defect is admitted default function type transfer, not blanket JavaScript or JSX admission.

Acceptance: preserve source-owned default function signatures across JS and JSX imports, including the no-global-checkJs case; retain TS6142/TS7016 negative option boundaries; compare real-file positive and negative controls with TypeScript; add Program/CLI regression tests; pass relevant serial guarded suites. No any fallback, source-name heuristics, or diagnostic suppression.

7 days ago

Fixed and pushed directly to origin/main as glennmichael123 without coauthors: e15a97a. The default export was already present in the declaration graph, but its schema was projection-only because JSDoc lookup stopped at default between the comment and function HIR span. The modifier walk now crosses the complete export default async prefix (and existing static/export cases) before associating the comment; no any fallback or admission shortcut was added. Regression tests assert the default function has a supported function schema and that default and named consumer calls both produce TS2322; CLI tests cover admitted .js and .jsx default imports. Fresh TypeScript 5.7.3 and rebuilt home-tsc both report exactly TS2322 at main.ts(2,7) for JS and JSX with allowJs. Negative JSX option controls remain exact: TS6142 without jsx mode, TS7016 with jsx mode but no allowJs. Guarded Program 427/427 and CLI 86/86 pass; checker target is cached-valid (checker source unchanged); fresh home-tsc build passed. #846 remains open for broader admission/LSP/imported-JS criteria.

Sign in to comment on this issue.