Skip to content

[15.5] Reject TypeScript >= 7.0 with an actionable error#96110

Merged
lukesandberg merged 3 commits into
next-15-5from
mitigation-reject-typescript-7-next-15-5
Jul 24, 2026
Merged

[15.5] Reject TypeScript >= 7.0 with an actionable error#96110
lukesandberg merged 3 commits into
next-15-5from
mitigation-reject-typescript-7-next-15-5

Conversation

@lukesandberg

Copy link
Copy Markdown
Contributor

Summary

A minimal mitigation for the TypeScript 7 problem on the 15.5.x line, ported from the next-16-2 mitigation (#95837).

TypeScript 7's native compiler no longer ships the JavaScript compiler API (typescript/lib/typescript.js) that Next.js loads via require('typescript'), so an installed TS7 produces surprising failures with no actionable message. This was reported against 16.2 in #95801.

What it does

  • Because the missing compiler-API file makes an installed TS7 look like a missing dependency, hasNecessaryDependencies now also exposes the resolved typescript/package.json path. verifyTypeScriptSetup reads that version up front and, if it's >= 7.0.0 (including prereleases — 7.0.0-beta/-rc, nightly 7.0.0-dev.*, via the 7.0.0-0 sentinel with includePrerelease), throws a CompileError with guidance to install TypeScript 6 or upgrade Next.js, before the require() runs.

Unlike the 16.2 mitigation, no install-specifier change is needed here: the 15.5 line already pins TypeScript auto-installs via getTypeScriptPackageSpec (typescript@5.8.2) rather than pulling latest.

Applies to both next dev and next build.

Notes

Verification

  • pnpm --filter=next build
  • Boundary verified against the compiled semver: 5.8.2 / 6.x (incl. 6.0.0-beta) are not rejected; 7.0.0-dev.* / 7.0.0-beta / 7.0.0-rc / 7.0.0 / 7.0.2 are rejected.
  • Manual repro with typescript@7 + next@15.5: next build and CI=1 next build exit non-zero with the actionable error instead of the opaque failure.

TypeScript 7's native compiler no longer ships the JavaScript compiler API
(`typescript/lib/typescript.js`) that Next.js loads via `require('typescript')`,
producing surprising failures with no actionable message. This was reported
against the 16.2 line in #95801.

Because the missing API file makes an installed TS7 look like a missing
dependency, expose the resolved `typescript/package.json` path from
`hasNecessaryDependencies` and check the installed version up front, throwing a
CompileError with guidance to install TypeScript 6 or upgrade Next.js before the
`require()` runs. Prereleases (7.0.0-beta/-rc, nightly 7.0.0-dev.*) are rejected
too via the `7.0.0-0` prerelease sentinel.

Minimal mitigation for the 15.5.x line; mirrors the next-16-2 mitigation (#95837).
Auto-install version is already pinned on this line via getTypeScriptPackageSpec,
so no install-specifier change is needed here.
@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Failing CI jobs

Commit: 131bdac | About building and testing Next.js

@lukesandberg
lukesandberg requested a review from bgw July 23, 2026 21:57
@lukesandberg
lukesandberg marked this pull request as ready for review July 23, 2026 21:58
@lukesandberg
lukesandberg enabled auto-merge (squash) July 23, 2026 22:14
The `next lint` first-time-setup tests install `eslint-config-next`, whose
transitive deps (e.g. `@typescript-eslint/*` pulling `eslint-visitor-keys@5`)
have dropped Node 18 support. npm/pnpm honor the `overrides` pin that works
around this, but yarn 1.x does not apply it to the tarball dependency, so the
install fails and `.eslintrc.json` is never written.

Drop the yarn install variant and skip the three default-package-manager
config-creation tests (which also resolve to yarn in the CI environment). The
npm and pnpm install variants still cover the first-time-setup path. This is a
15.5-only maintenance-branch workaround; the failure is unrelated to product
code.
@lukesandberg
lukesandberg merged commit fcc0424 into next-15-5 Jul 24, 2026
489 of 498 checks passed
@lukesandberg
lukesandberg deleted the mitigation-reject-typescript-7-next-15-5 branch July 24, 2026 07:10
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.

2 participants