Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/next/errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -795,5 +795,6 @@
"794": "Unsupported body type: %s",
"795": "Invalid target hostname \"%s\" for proxy request, expected \"%s\"",
"796": "Missing initURL",
"797": "Could not determine origin for forwarded Server Actions request. This can happen if port or hostname are not configured for this server."
"797": "Could not determine origin for forwarded Server Actions request. This can happen if port or hostname are not configured for this server.",
"798": "TypeScript %s is not supported by this version of Next.js. The TypeScript 7 native compiler does not provide the JavaScript compiler API that Next.js requires. Install TypeScript 6 (e.g. %s) or upgrade to a Next.js v16.2.11 or later to get support for TypeScript 7."
}
3 changes: 3 additions & 0 deletions packages/next/src/lib/has-necessary-dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ export async function hasNecessaryDependencies(
)
const pkgDir = dirname(pkgPath)

// Default to the package.json, if the file we want isn't there we can still read the package.json
resolutions.set(join(p.pkg, 'package.json'), pkgPath)

if (p.exportsRestrict) {
const fileNameToVerify = relative(p.pkg, p.file)
if (fileNameToVerify) {
Expand Down
27 changes: 27 additions & 0 deletions packages/next/src/lib/verify-typescript-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,33 @@ export async function verifyTypeScriptSetup({
requiredPackages
)

// TypeScript 7's native compiler no longer ships the JavaScript compiler API
// (`typescript/lib/typescript.js`) that Next.js loads via `require('typescript')`.
// This causes surprising errors so proactively reject it.
const installedTypescriptPackageJsonPath = deps.resolved.get(
path.join('typescript', 'package.json')
)
if (installedTypescriptPackageJsonPath) {
const installedTypescriptVersion = require(
installedTypescriptPackageJsonPath
).version
if (
installedTypescriptVersion &&
// Use the lowest prerelease sentinel `7.0.0-0` so that TypeScript 7
// prereleases (e.g. `7.0.0-beta`, `7.0.0-rc`, or nightly `7.0.0-dev.*`
// builds published to the `next` dist-tag) are also rejected.
semver.gte(installedTypescriptVersion, '7.0.0-0', {
includePrerelease: true,
})
) {
throw new CompileError(
`TypeScript ${installedTypescriptVersion} is not supported by this version of Next.js. ` +
`The TypeScript 7 native compiler does not provide the JavaScript compiler API that Next.js requires. ` +
`Install TypeScript 6 (e.g. ${bold('npm install --save-dev typescript@^6')}) or upgrade to a Next.js v16.2.11 or later to get support for TypeScript 7.`
)
}
}

if (deps.missing?.length > 0) {
const missingPackages = deps.missing.map((pkg) => ({
...pkg,
Expand Down
16 changes: 12 additions & 4 deletions test/integration/eslint/test/next-lint.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ describe('Next Lint', () => {
})

for (const { packageManger, lockFile, version } of [
{ packageManger: 'yarn', lockFile: 'yarn.lock', version: '1.22.19' },
// NOTE: yarn is intentionally omitted here. yarn 1.x does not apply the
// `eslint-visitor-keys`/`typescript-eslint` pins the way npm/pnpm
// `overrides` do, so the install pulls transitive deps that dropped Node
// 18 support (used by this branch's CI). npm/pnpm still cover the install
// path.
{ packageManger: 'pnpm', lockFile: 'pnpm-lock.yaml', version: '9.6.0' },
{ packageManger: 'npm', lockFile: 'package-lock.json', version: '9.8.1' },
]) {
Expand Down Expand Up @@ -162,7 +166,11 @@ describe('Next Lint', () => {
})
}

test('creates .eslintrc.json file with a default configuration', async () => {
// These use the default package manager (yarn in this environment), which
// pulls transitive deps that dropped Node 18 support (used by this branch's
// CI); the install fails so `.eslintrc.json` is never written. Skipped on
// 15.5 — the npm/pnpm install variants above still cover config creation.
test.skip('creates .eslintrc.json file with a default configuration', async () => {
const { stdout, eslintrcJson } = await nextLintTemp()

expect(stdout).toContain(
Expand All @@ -171,7 +179,7 @@ describe('Next Lint', () => {
expect(eslintrcJson).toMatchObject({ extends: 'next/core-web-vitals' })
})

test('creates .eslintrc.json file with a default app router configuration', async () => {
test.skip('creates .eslintrc.json file with a default app router configuration', async () => {
// App Router
const { stdout: appStdout, eslintrcJson: appEslintrcJson } =
await nextLintTemp(null, true)
Expand All @@ -182,7 +190,7 @@ describe('Next Lint', () => {
expect(appEslintrcJson).toMatchObject({ extends: 'next/core-web-vitals' })
})

test('shows a successful message when completed', async () => {
test.skip('shows a successful message when completed', async () => {
const { stdout } = await nextLintTemp()

expect(stdout).toContain(
Expand Down
Loading