Skip to content

Move apps/web to TypeScript 7 once @astrojs/check supports it #610

Description

@zachdunn

Summary

apps/web is the one workspace package still on TypeScript ^6.0.3. Everything else moved to 7.0.2 in #609. This tracks finishing the job once Astro supports it.

Why it's blocked

@astrojs/check@0.9.10 (latest at time of writing) declares:

"peerDependencies": { "typescript": "^5.0.0 || ^6.0.0" }

TypeScript 7 is excluded upstream, so this isn't something a version bump on our side can fix.

The underlying cause is that TypeScript 7's npm package no longer ships the JS compiler API — its main export is just lib/version.cjs, with ts.createProgram and the language service moved behind typescript/unstable/*. @astrojs/check reaches the API through @astrojs/language-server@volar/typescript, so on TS7 it fails at startup:

Cannot read properties of undefined (reading 'fileExists')
  at AstroCheck.getTsconfig (@astrojs/language-server/dist/check.js:162)

Note this is specific to astro check. astro build already works on TypeScript 7 (verified, exit 0) — it goes through esbuild/vite and never touches the TS API. So there's no build risk here, only type coverage.

Why we didn't work around it

Two options were tested during #609 and both rejected:

  • Aliasing a second TypeScript (typescript@6 for astro check + an aliased 7 for tsc) doesn't work cleanly. pnpm resolves a peer dep from the host package, so @astrojs/check would still receive 7. It would need a real typescript@6 plus an alias whose tsc bin collides in .bin, invoked by absolute path.
  • Dropping astro check trades away far more than it gains. tsconfig.worker.json — web's only direct tsc use — covers 4 files. astro check covers 149. Upgrading would speed up 4 files and remove type coverage from 149.

Waiting is the right call.

Trigger

Astro ships a @astrojs/check (or @astrojs/language-server / @volar/typescript) release whose typescript peer range admits ^7. Worth re-checking periodically:

npm view @astrojs/check peerDependencies --json

The change

One line in apps/web/package.json:

-    "typescript": "^6.0.3",
+    "typescript": "^7.0.2",

Then pnpm install and confirm pnpm --filter @uploads/web typecheck passes — that script runs wrangler types && astro check && tsc -p tsconfig.worker.json --noEmit, so it exercises the whole path. Baseline to match: 150 files, 0 errors.

Watch for TS5011 (TypeScript 7 rejects an inferred rootDir) if any emit config is touched — that's the one behavior change we hit in #609.

Done when

  • apps/web is on typescript@^7
  • astro check passes at 0 errors
  • All 12 workspace packages report the same TypeScript major

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions