[GH-ISSUE #3780] [Bug] JavaScript sources are parsed with the TypeScript plugin; valid bundles fail (VS Code workbench) or gain false facts #1467

Closed
opened 2026-10-16 21:05:43 +00:00 by bsakaguchi · 0 comments
Owner

Originally created by @kaoru0822-kitauji on GitHub (Oct 15, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/3780

Summary: .js, .jsx, .mjs and .cjs artifact sources are parsed with Babel's typescript plugin enabled (parserPluginsForPath). TypeScript reads some valid JavaScript differently:

  • c?H=>({a:H.x}):H=>({a:H.y}): TypeScript reads ):H=> as an arrow return-type annotation and throws "Unexpected token, expected ':'". parseJavaScriptSource returns null, so the whole file is parse_status: "failed".
  • fetch<limit>("/api"): in JavaScript this is (fetch < limit) > "/api". TypeScript reads it as a generic call, so static analysis reports an endpoint that does not exist.
  • A misparse earlier in a file can also produce false recovered errors later on. In Claude.app's .vite/build/heavy-work-worker/dist-*.js the TypeScript parse reports 'return' outside of function, while the JavaScript grammar parses with no errors.

Real-world impact: VS Code 1.11x resources/app/out/vs/workbench/workbench.desktop.main.js (20.3 MB) and out/vs/sessions/sessions.desktop.main.js (21.3 MB) both throw at line 550 (n===0?H=>({sash:f,…}):H=>({…})). This is the parse_status: "failed" / parse_failures: 2 that #3670 reports for VSCodium's main renderer bundles, which are about 68% of the text read.

Repro:

// main.js
const {ipcMain}=require("electron");
const pick=n===0?H=>({start:H.startY}):H=>({start:H.startX});
ipcMain.handle("layout:ready",()=>pick);

parseJavaScriptSource(source, "main.js") returns null on current main.

Measured on real application code (3,732 .js/.mjs/.cjs files from Discord, Notion, Signal, Claude, Tabby and VS Code out/ + node_modules): JavaScript grammar (JSX + legacy decorators, no TypeScript) throws on 0 files, while the TypeScript plugin throws on 2. Static facts are identical on 3,729 of the 3,730 files that both grammars parse; the one difference is the false TypeScript error above. Parse time is 5,606 ms with the TypeScript plugin and 4,644 ms with JavaScript grammar.

Expected: JavaScript sources parse with JavaScript grammar. TypeScript dialects and unnamed sources keep the current TypeScript-capable contract.

Originally created by @kaoru0822-kitauji on GitHub (Oct 15, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/3780 **Summary:** `.js`, `.jsx`, `.mjs` and `.cjs` artifact sources are parsed with Babel's `typescript` plugin enabled (`parserPluginsForPath`). TypeScript reads some valid JavaScript differently: - `c?H=>({a:H.x}):H=>({a:H.y})`: TypeScript reads `):H=>` as an arrow return-type annotation and **throws** "Unexpected token, expected ':'". `parseJavaScriptSource` returns `null`, so the whole file is `parse_status: "failed"`. - `fetch<limit>("/api")`: in JavaScript this is `(fetch < limit) > "/api"`. TypeScript reads it as a generic call, so static analysis reports an endpoint that does not exist. - A misparse earlier in a file can also produce false recovered errors later on. In Claude.app's `.vite/build/heavy-work-worker/dist-*.js` the TypeScript parse reports `'return' outside of function`, while the JavaScript grammar parses with no errors. **Real-world impact:** VS Code 1.11x `resources/app/out/vs/workbench/workbench.desktop.main.js` (20.3 MB) and `out/vs/sessions/sessions.desktop.main.js` (21.3 MB) both throw at line 550 (`n===0?H=>({sash:f,…}):H=>({…})`). This is the `parse_status: "failed"` / `parse_failures: 2` that #3670 reports for VSCodium's main renderer bundles, which are about 68% of the text read. **Repro:** ```js // main.js const {ipcMain}=require("electron"); const pick=n===0?H=>({start:H.startY}):H=>({start:H.startX}); ipcMain.handle("layout:ready",()=>pick); ``` `parseJavaScriptSource(source, "main.js")` returns `null` on current `main`. **Measured on real application code** (3,732 `.js/.mjs/.cjs` files from Discord, Notion, Signal, Claude, Tabby and VS Code `out/` + `node_modules`): JavaScript grammar (JSX + legacy decorators, no TypeScript) throws on 0 files, while the TypeScript plugin throws on 2. Static facts are identical on 3,729 of the 3,730 files that both grammars parse; the one difference is the false TypeScript error above. Parse time is 5,606 ms with the TypeScript plugin and 4,644 ms with JavaScript grammar. **Expected:** JavaScript sources parse with JavaScript grammar. TypeScript dialects and unnamed sources keep the current TypeScript-capable contract.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#1467
No description provided.