Skip to content

Commit 62098bb

Browse files
aslakhellesoyclaude
andcommitted
build(ts): upgrade the toolchain to TypeScript 7
TypeScript 7 is the native Go compiler. Type-checking the workspace drops from 1.18s to 0.28s over an identical 545-file graph, and the emit is equivalent: .d.ts output is byte-identical to 6's, and the .js differs only in quote style on module specifiers (7 preserves the source's single quotes where 6 normalised to double). packages/website stays on typescript@6 — the last JS-implemented release. Its example editors type-check (ts-diagnostics.ts) and transpile (run-worker.ts) *in the browser*, and TypeScript 7 has no in-process API to do that with: `import * as ts from 'typescript'` now resolves to a module exporting nothing but a version string, and the real API spawns the tsgo binary and talks to it over a pipe. No WASM build of tsgo exists yet (microsoft/typescript-go#3478, #4633) — the official TypeScript Playground tops out at 6.0.3 and Monaco still bundles the 5.9 JS compiler. 7 also moved lib.*.d.ts out of the `typescript` package into the per-platform binary packages, where the editors' import.meta.glob would find nothing. @astrojs/check pins the website to ^5 || ^6 regardless. pnpm keeps the two versions apart per package. scripts/lint-no-reexports.mjs used ts.createSourceFile, which no longer exists; it now parses through typescript/unstable/sync and keeps its predicates via unstable/ast/is. The node shapes are unchanged, so the rule itself is untouched — verified against injected violations of all three forms it rejects. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01HDv69cahZVx96PCbxiRpqg
1 parent fd5a2ab commit 62098bb

8 files changed

Lines changed: 297 additions & 23 deletions

File tree

‎CLAUDE.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,19 @@ If a function in `packages/varar/src/` needs to read a file, it doesn't — it t
8080

8181
pnpm workspace · biome · vitest (for the core's own tests) · knip · jscpd · TypeScript (ESM-only, `node:` imports, Node ≥ 22 LTS).
8282

83+
**TypeScript 7 everywhere except the website.** 7 is the native Go compiler:
84+
`tsc` is a binary and the only programmatic API (`typescript/unstable/*`) spawns
85+
it and talks over a pipe — `import * as ts from 'typescript'` no longer returns
86+
a compiler. `packages/website` therefore stays pinned to `typescript@6`, the
87+
last JS-implemented release, because its example editors type-check and
88+
transpile *in the browser* (`src/lib/ts-diagnostics.ts`, `src/lib/run-worker.ts`)
89+
and `@astrojs/check` peer-depends on `^5 || ^6` besides. There is no WASM build
90+
of tsgo yet — Microsoft has committed to one for the playground and vscode.dev
91+
but published nothing (microsoft/typescript-go#3478, #4633), and the official
92+
Playground and Monaco are still on the JS compiler too. Revisit when a
93+
browser-instantiable tsgo ships. pnpm keeps the two versions apart per package,
94+
so this costs nothing but the pin.
95+
8396
## Workflow
8497

8598
- **Root gate.** `make check` (or plain `make`) at the repo root builds and tests

‎examples/typescript-vitest/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"@varar/varar": "workspace:*",
1616
"@varar/vitest": "workspace:*",
1717
"@types/node": "^26.1.0",
18-
"typescript": "^6.0.3",
18+
"typescript": "^7.0.2",
1919
"vitest": "^4.1.10"
2020
},
2121
"license": "MIT",

‎typescript/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"@vitest/coverage-v8": "^4.1.10",
2828
"jscpd": "^5.0.11",
2929
"knip": "^6.25.0",
30-
"typescript": "^6.0.3",
30+
"typescript": "^7.0.2",
3131
"vite": "^8.1.3",
3232
"vitest": "^4.1.10"
3333
}

‎typescript/packages/language/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"dependencies": {
2222
"@cucumber/cucumber-expressions": "^20.0.0",
2323
"@varar/core": "workspace:*",
24-
"typescript": "^6.0.3",
24+
"typescript": "^7.0.2",
2525
"web-tree-sitter": "^0.26.10"
2626
},
2727
"devDependencies": {

‎typescript/packages/website/src/lib/run-worker.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import * as varCore from '@varar/core'
22
import { type Drift, hashSource, type OathResults } from '@varar/core'
33
import * as varRuntime from '@varar/varar'
44
import { _resetBuilder } from '@varar/varar/registry'
5+
// typescript 6, not the workspace's 7 — `transpileModule` runs in-process in
6+
// the browser and TypeScript 7 has no such API. See ts-diagnostics.ts.
57
import * as ts from 'typescript'
68
import { createMemoryBaselineStore } from './memory-baseline-store.ts'
79
import { resolveRelative } from './module-resolution.ts'

‎typescript/packages/website/src/lib/ts-diagnostics.ts‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1+
// This package pins typescript 6 while the rest of the workspace is on 7 (see
2+
// the version in package.json). TypeScript 7 is the native Go compiler: its
3+
// only programmatic API spawns the tsgo binary and talks to it over a pipe, so
4+
// there is no in-process `createLanguageService` and nothing that runs in a
5+
// browser. Microsoft has committed to a WASM build for the playground and
6+
// vscode.dev but published none (microsoft/typescript-go#3478, #4633), and the
7+
// official TypeScript Playground and Monaco are themselves still on the
8+
// JavaScript compiler. Until a browser-instantiable tsgo exists, in-editor
9+
// type-checking here stays on 6 — the last JS-implemented release.
110
import * as ts from 'typescript'
211

312
// Bundled TypeScript lib .d.ts files, keyed by basename (e.g. "lib.es2020.d.ts").
4-
// Vite/Vitest resolve this glob at build/test time; no CDN.
13+
// Vite/Vitest resolve this glob at build/test time; no CDN. (Another thing the
14+
// 6 pin buys: TypeScript 7 moved these out of the `typescript` package into the
15+
// per-platform binary packages, where this glob would find nothing.)
516
const libModules = import.meta.glob('/node_modules/typescript/lib/lib.*.d.ts', {
617
query: '?raw',
718
eager: true,

‎typescript/pnpm-lock.yaml‎

Lines changed: 214 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)