Skip to content

fix(source-analysis): Parse with @typescript/typescript6 - #119

Closed
scttcper wants to merge 1 commit into
mainfrom
scttcper/source-analysis-typescript6
Closed

scttcper wants to merge 1 commit into
mainfrom
scttcper/source-analysis-typescript6

Conversation

@scttcper

Copy link
Copy Markdown
Member

TypeScript 7 doesn't ship the JS compiler API anymore, import ts from "typescript" only gets you a version string. The optional typescript peer resolves to whatever the project compiles with, so source-analysis crashes on ts.ScriptTarget.Latest in any project on 7.

Swaps the peer for an optional @typescript/typescript6, TypeScript's own package for code that still needs the 6 API. The analyzer only parses, so it behaves the same and no longer depends on the project's compiler.

One gotcha: @typescript/typescript6 depends on @typescript/old, a full typescript@6 alias with its own tsc bin. npm and bun hoist it, so node_modules/.bin/tsc becomes 6.0.3 even next to typescript 5.9 or 7 (pnpm keeps it nested). Build and typecheck here now run the repo's own compiler by path, and the README mentions it.

Follow-up to #115

TypeScript 7 doesn't ship the JS compiler API anymore, `import ts from
"typescript"` just gets you a version string. The optional `typescript`
peer resolves to whatever the project compiles with, so in toolkit (now
on 7) the analyzer crashes on `ts.ScriptTarget.Latest`.

Swap the peer for an optional `@typescript/typescript6`, TypeScript's own
package for code that still needs the 6 API. The analyzer only parses, so
nothing else changes and it stops caring which tsc the project uses.

The alias inside that package is a full typescript@6 with its own `tsc`
bin, and bun hoists it over ours, so build and typecheck now call this
repo's 5.9 compiler by path. The README calls out the same thing for npm
and bun users.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@scttcper scttcper closed this Oct 30, 2026
@scttcper
scttcper deleted the scttcper/source-analysis-typescript6 branch October 30, 2026 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant