[15.5] Reject TypeScript >= 7.0 with an actionable error#96110
Merged
lukesandberg merged 3 commits intoJul 24, 2026
Conversation
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.
Contributor
Failing CI jobsCommit: 131bdac | About building and testing Next.js |
lukesandberg
marked this pull request as ready for review
July 23, 2026 21:58
bgw
approved these changes
Jul 23, 2026
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A minimal mitigation for the TypeScript 7 problem on the
15.5.xline, ported from thenext-16-2mitigation (#95837).TypeScript 7's native compiler no longer ships the JavaScript compiler API (
typescript/lib/typescript.js) that Next.js loads viarequire('typescript'), so an installed TS7 produces surprising failures with no actionable message. This was reported against 16.2 in #95801.What it does
hasNecessaryDependenciesnow also exposes the resolvedtypescript/package.jsonpath.verifyTypeScriptSetupreads that version up front and, if it's>= 7.0.0(including prereleases —7.0.0-beta/-rc, nightly7.0.0-dev.*, via the7.0.0-0sentinel withincludePrerelease), throws aCompileErrorwith guidance to install TypeScript 6 or upgrade Next.js, before therequire()runs.Unlike the 16.2 mitigation, no install-specifier change is needed here: the
15.5line already pins TypeScript auto-installs viagetTypeScriptPackageSpec(typescript@5.8.2) rather than pullinglatest.Applies to both
next devandnext build.Notes
15.5; the fullexperimental.useTypeScriptClibackend (real TS7 support) is a separate, larger effort and was considered overkill for this stable line.next-16-2mitigation [16.2] Reject TypeScript >= 7.0 with an actionable error (mitigation for #95801) #95837, and full backport [Backport] Fixes to support TypeScript 7 #95831.Verification
pnpm --filter=next build5.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.2are rejected.typescript@7+next@15.5:next buildandCI=1 next buildexit non-zero with the actionable error instead of the opaque failure.