Unverified Commit 403cd058 authored by vercel-fleet-prod[bot]'s avatar vercel-fleet-prod[bot] Committed by GitHub

Fix TypeScript CLI checking with debug build paths

Co-authored-by: 's avatarNiklas Mischkulnig <4586894+mischnic@users.noreply.github.com>
parent 8e870bc4
...@@ -55,7 +55,7 @@ If you opt out while using TypeScript 7, `next build` exits because the TypeScri ...@@ -55,7 +55,7 @@ If you opt out while using TypeScript 7, `next build` exits because the TypeScri
- Next.js continues to generate `next-env.d.ts` and route types and to apply its recommended `tsconfig` settings before running the checker. - Next.js continues to generate `next-env.d.ts` and route types and to apply its recommended `tsconfig` settings before running the checker.
- TypeScript diagnostics are printed directly from `tsc`. Next.js-specific code frames and error rewriting are not applied. - TypeScript diagnostics are printed directly from `tsc`. Next.js-specific code frames and error rewriting are not applied.
- The complete project selected by the configured `tsconfig` file is checked, including test files and `.next/dev/types` when included. The [`--debug-build-paths`](/docs/app/api-reference/cli/next#next-build-options) option does not limit this set and produces a warning when combined with the CLI checker. - The complete project selected by the configured `tsconfig` file is checked, including test files and `.next/dev/types` when included. With [`--debug-build-paths`](/docs/app/api-reference/cli/next#building-specific-routes), only selected files in the App and Pages Router directories are included as type-checking roots. Shared files outside those directories and dependencies imported by retained files are still checked.
- [`typescript.tsconfigPath`](/docs/app/api-reference/config/typescript#custom-tsconfig-path) selects the project passed to `tsc`. - [`typescript.tsconfigPath`](/docs/app/api-reference/config/typescript#custom-tsconfig-path) selects the project passed to `tsc`.
- [`typescript.ignoreBuildErrors`](/docs/app/api-reference/config/typescript#disabling-typescript-errors-in-production) skips the type-checking step, including the CLI checker. - [`typescript.ignoreBuildErrors`](/docs/app/api-reference/config/typescript#disabling-typescript-errors-in-production) skips the type-checking step, including the CLI checker.
......
...@@ -36,7 +36,7 @@ Next.js uses the project-local `tsc` CLI by default, so no additional configurat ...@@ -36,7 +36,7 @@ Next.js uses the project-local `tsc` CLI by default, so no additional configurat
> **Good to know**: > **Good to know**:
> >
> - CLI type checking prints the native `tsc` diagnostics. It does not apply Next.js-specific code frames or rewrite errors for routes, pages, layouts, or route handlers. > - CLI type checking prints the native `tsc` diagnostics. It does not apply Next.js-specific code frames or rewrite errors for routes, pages, layouts, or route handlers.
> - The CLI checks the complete project selected by your `tsconfig` file. This includes test files and `.next/dev/types` when they are included by that configuration. [`next build --debug-build-paths`](/docs/app/api-reference/cli/next#next-build-options) does not narrow the files that are type checked and produces a warning when used with this option. > - The CLI checks the complete project selected by your `tsconfig` file. This includes test files and `.next/dev/types` when they are included by that configuration. With [`next build --debug-build-paths`](/docs/app/api-reference/cli/next#building-specific-routes), only selected files in the App and Pages Router directories are included as type-checking roots. Shared files outside those directories and dependencies imported by retained files are still checked.
> - [`typescript.tsconfigPath`](#custom-tsconfig-path) continues to select the configuration passed to `tsc`. [`typescript.ignoreBuildErrors`](#disabling-typescript-errors-in-production) skips the type-checking step, including the CLI checker. > - [`typescript.tsconfigPath`](#custom-tsconfig-path) continues to select the configuration passed to `tsc`. [`typescript.ignoreBuildErrors`](#disabling-typescript-errors-in-production) skips the type-checking step, including the CLI checker.
> - `experimental.useTypeScriptCli` is experimental and its behavior may change. > - `experimental.useTypeScriptCli` is experimental and its behavior may change.
......
import path from 'node:path'
export interface TypeCheckDirs {
app?: string
pages?: string
}
export interface DebugBuildPaths {
app?: string[]
pages?: string[]
}
/** Filter roots, not diagnostics: TypeScript still checks their imports. */
export function filterTypeScriptFiles(
fileNames: string[],
dirs: TypeCheckDirs,
debugBuildPaths: DebugBuildPaths
): string[] {
return fileNames.filter((fileName) => {
for (const router of ['app', 'pages'] as const) {
const dir = dirs[router]
if (dir && fileName.startsWith(dir + path.sep)) {
const debugPaths = debugBuildPaths[router]
// Undefined means unrestricted; an empty selection excludes all roots.
return (
debugPaths === undefined ||
debugPaths.includes(fileName.slice(dir.length))
)
}
}
// Retain shared files outside the route directories.
return true
})
}
...@@ -3,6 +3,13 @@ import { getFormattedDiagnostic } from './diagnosticFormatter' ...@@ -3,6 +3,13 @@ import { getFormattedDiagnostic } from './diagnosticFormatter'
import { getTypeScriptConfiguration } from './getTypeScriptConfiguration' import { getTypeScriptConfiguration } from './getTypeScriptConfiguration'
import { getRequiredConfiguration } from './writeConfigurationDefaults' import { getRequiredConfiguration } from './writeConfigurationDefaults'
import { getDevTypesPath } from './type-paths' import { getDevTypesPath } from './type-paths'
import {
filterTypeScriptFiles,
type TypeCheckDirs,
type DebugBuildPaths,
} from './filterTypeScriptFiles'
export type { TypeCheckDirs, DebugBuildPaths } from './filterTypeScriptFiles'
import { CompileError } from '../compile-error' import { CompileError } from '../compile-error'
import { warn } from '../../build/output/log' import { warn } from '../../build/output/log'
...@@ -13,27 +20,6 @@ export interface TypeCheckResult { ...@@ -13,27 +20,6 @@ export interface TypeCheckResult {
incremental: boolean incremental: boolean
} }
export interface TypeCheckDirs {
app?: string
pages?: string
}
export interface DebugBuildPaths {
app?: string[]
pages?: string[]
}
/**
* Check if a file path matches any of the debug build paths.
* Both filePath and debugPaths are resolved file paths from glob.
*/
function fileMatchesDebugPaths(
filePath: string,
debugPaths: string[]
): boolean {
return debugPaths.includes(filePath)
}
export async function runTypeCheck( export async function runTypeCheck(
typescript: typeof import('typescript'), typescript: typeof import('typescript'),
baseDir: string, baseDir: string,
...@@ -65,43 +51,7 @@ export async function runTypeCheck( ...@@ -65,43 +51,7 @@ export async function runTypeCheck(
// Apply debug build paths filter if specified // Apply debug build paths filter if specified
if (dirs && debugBuildPaths) { if (dirs && debugBuildPaths) {
const { app: appDir, pages: pagesDir } = dirs fileNames = filterTypeScriptFiles(fileNames, dirs, debugBuildPaths)
const { app: debugAppPaths, pages: debugPagePaths } = debugBuildPaths
fileNames = fileNames.filter((fileName) => {
// Check if file is in app directory
if (appDir && fileName.startsWith(appDir + path.sep)) {
// If debugAppPaths is undefined, include all app files
if (debugAppPaths === undefined) {
return true
}
// If debugAppPaths is empty array, exclude all app files
if (debugAppPaths.length === 0) {
return false
}
// Check if file matches any of the debug paths
const relativeToApp = fileName.slice(appDir.length)
return fileMatchesDebugPaths(relativeToApp, debugAppPaths)
}
// Check if file is in pages directory
if (pagesDir && fileName.startsWith(pagesDir + path.sep)) {
// If debugPagePaths is undefined, include all pages files
if (debugPagePaths === undefined) {
return true
}
// If debugPagePaths is empty array, exclude all pages files
if (debugPagePaths.length === 0) {
return false
}
// Check if file matches any of the debug paths
const relativeToPages = fileName.slice(pagesDir.length)
return fileMatchesDebugPaths(relativeToPages, debugPagePaths)
}
// Keep files outside app/pages directories (shared code, etc.)
return true
})
} }
if (fileNames.length < 1) { if (fileNames.length < 1) {
......
import { randomUUID } from 'node:crypto'
import { rmSync } from 'node:fs'
import { writeFile } from 'node:fs/promises'
import path from 'node:path' import path from 'node:path'
import { CompileError } from '../compile-error' import { CompileError } from '../compile-error'
import type { TypeCheckResult } from './runTypeCheck' import type { TypeCheckResult } from './runTypeCheck'
import {
filterTypeScriptFiles,
type DebugBuildPaths,
type TypeCheckDirs,
} from './filterTypeScriptFiles'
import { import {
getTypeScriptConfigurationCli, getTypeScriptConfigurationCli,
runTypeScriptCli, runTypeScriptCli,
...@@ -12,12 +20,16 @@ export async function runTypeCheckCli({ ...@@ -12,12 +20,16 @@ export async function runTypeCheckCli({
tsConfigPath, tsConfigPath,
tscPath, tscPath,
cacheDir, cacheDir,
dirs,
debugBuildPaths,
onFirstOutput, onFirstOutput,
}: { }: {
baseDir: string baseDir: string
tsConfigPath: string tsConfigPath: string
tscPath: string tscPath: string
cacheDir?: string cacheDir?: string
dirs?: TypeCheckDirs
debugBuildPaths?: DebugBuildPaths
/** /**
* Called once when `tsc` first produces output. Used to stop the build * Called once when `tsc` first produces output. Used to stop the build
* spinner so it does not sit above the diagnostics. * spinner so it does not sit above the diagnostics.
...@@ -33,9 +45,47 @@ export async function runTypeCheckCli({ ...@@ -33,9 +45,47 @@ export async function runTypeCheckCli({
configuration.compilerOptions.incremental || configuration.compilerOptions.incremental ||
configuration.compilerOptions.composite configuration.compilerOptions.composite
) )
let projectPath = tsConfigPath
let cleanup: (() => void) | undefined
if (dirs && debugBuildPaths) {
const configDir = path.dirname(path.resolve(baseDir, tsConfigPath))
const fileNames = filterTypeScriptFiles(
(configuration.files ?? []).map((file) => path.resolve(configDir, file)),
dirs,
debugBuildPaths
)
if (fileNames.length === 0) {
return { incremental: false }
}
// Keep the config alongside the original so config-relative options (and
// TypeScript 7's default rootDir) retain their meaning. Extending the original
// preserves inherited options without loading the TypeScript compiler API.
projectPath = path.join(
configDir,
`.next-debug-tsconfig-${randomUUID()}.json`
)
await writeFile(
projectPath,
JSON.stringify({
extends: `./${path.basename(tsConfigPath)}`,
files: fileNames,
include: [],
// Unlike compiler options, project references are not inherited.
references: configuration.references,
}),
{ flag: 'wx', mode: 0o600 }
)
cleanup = () => rmSync(projectPath, { force: true })
// runTypeScriptCli exits directly on termination signals, bypassing finally.
process.once('exit', cleanup)
}
try {
const args = [ const args = [
'--project', '--project',
tsConfigPath, projectPath,
'--noEmit', '--noEmit',
'--declarationMap', '--declarationMap',
'false', 'false',
...@@ -58,7 +108,11 @@ export async function runTypeCheckCli({ ...@@ -58,7 +108,11 @@ export async function runTypeCheckCli({
throw new CompileError() throw new CompileError()
} }
return { return { incremental }
incremental, } finally {
if (cleanup) {
process.off('exit', cleanup)
cleanup()
}
} }
} }
import type { ChildProcess } from 'node:child_process' import type { ChildProcess } from 'node:child_process'
import { EventEmitter } from 'node:events' import { EventEmitter } from 'node:events'
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs' import {
existsSync,
mkdirSync,
mkdtempSync,
readFileSync,
readdirSync,
rmSync,
writeFileSync,
} from 'node:fs'
import { tmpdir } from 'node:os' import { tmpdir } from 'node:os'
import path from 'node:path' import path from 'node:path'
import { PassThrough } from 'node:stream' import { PassThrough } from 'node:stream'
import { filterTypeScriptFiles } from './filterTypeScriptFiles'
import { runTypeCheckCli } from './runTypeCheckCli'
import * as typescriptCli from './runTypeScriptCli'
const mockSpawn = jest.fn() const mockSpawn = jest.fn()
jest.mock('./runTypeScriptCli', () => ({
__esModule: true,
...jest.requireActual('./runTypeScriptCli'),
}))
jest.mock('next/dist/compiled/cross-spawn', () => ({ jest.mock('next/dist/compiled/cross-spawn', () => ({
__esModule: true, __esModule: true,
default: (...args: unknown[]) => mockSpawn(...args), default: (...args: unknown[]) => mockSpawn(...args),
...@@ -358,3 +374,142 @@ describe('runTypeScriptCli', () => { ...@@ -358,3 +374,142 @@ describe('runTypeScriptCli', () => {
expectListenersRestored() expectListenersRestored()
}) })
}) })
describe('filtered TypeScript CLI projects', () => {
let baseDir: string
let tsConfigPath: string
let configSpy: jest.SpyInstance
let runSpy: jest.SpyInstance
let projectPath: string
beforeEach(() => {
baseDir = mkdtempSync(path.join(tmpdir(), 'next-typescript-filter-'))
tsConfigPath = path.join(baseDir, 'config', 'tsconfig.build.json')
mkdirSync(path.dirname(tsConfigPath))
writeFileSync(tsConfigPath, '{ "extends": "./base.json" }')
configSpy = jest
.spyOn(typescriptCli, 'getTypeScriptConfigurationCli')
.mockResolvedValue({
compilerOptions: { incremental: true },
files: [
'../src/app/page.tsx',
'../src/app/excluded/page.tsx',
'../src/shared.ts',
],
references: [{ path: './referenced' }],
})
runSpy = jest.spyOn(typescriptCli, 'runTypeScriptCli')
})
afterEach(() => {
configSpy.mockRestore()
runSpy.mockRestore()
rmSync(baseDir, { recursive: true, force: true })
})
function check() {
return runTypeCheckCli({
baseDir,
tsConfigPath,
tscPath: 'tsc',
cacheDir: path.join(baseDir, '.next/cache'),
dirs: { app: path.join(baseDir, 'src/app') },
debugBuildPaths: { app: [path.join(path.sep, 'page.tsx')] },
})
}
it('uses selected roots and cleans up without modifying the original config', async () => {
runSpy.mockImplementation(async ({ args }) => {
projectPath = args[1]
const config = JSON.parse(readFileSync(projectPath, 'utf8'))
expect(path.dirname(projectPath)).toBe(path.dirname(tsConfigPath))
expect(config.extends).toBe('./tsconfig.build.json')
expect(config.files).toEqual([
path.join(baseDir, 'src/app/page.tsx'),
path.join(baseDir, 'src/shared.ts'),
])
expect(config.include).toEqual([])
expect(config.references).toEqual([{ path: './referenced' }])
return { exitCode: 0, signal: null, stdout: '', stderr: '' }
})
await expect(check()).resolves.toEqual({ incremental: true })
expect(runSpy).toHaveBeenCalledWith(
expect.objectContaining({
args: expect.arrayContaining([
'--tsBuildInfoFile',
path.join(baseDir, '.next/cache/.tsbuildinfo'),
]),
})
)
expect(existsSync(projectPath)).toBe(false)
expect(readFileSync(tsConfigPath, 'utf8')).toBe(
'{ "extends": "./base.json" }'
)
})
it.each(['diagnostics', 'spawn failure'])(
'cleans up after %s',
async (failure) => {
runSpy.mockImplementation(async ({ args }) => {
projectPath = args[1]
expect(existsSync(projectPath)).toBe(true)
if (failure === 'spawn failure') throw new Error('spawn failed')
return { exitCode: 1, signal: null, stdout: '', stderr: '' }
})
await expect(check()).rejects.toThrow()
expect(existsSync(projectPath)).toBe(false)
expect(readdirSync(path.dirname(tsConfigPath))).toEqual([
'tsconfig.build.json',
])
}
)
it('does not invoke tsc when all roots are excluded', async () => {
configSpy.mockResolvedValue({
compilerOptions: {},
files: ['../src/app/excluded/page.tsx'],
})
await expect(check()).resolves.toEqual({ incremental: false })
expect(runSpy).not.toHaveBeenCalled()
expect(readdirSync(path.dirname(tsConfigPath))).toEqual([
'tsconfig.build.json',
])
})
it('uses the original project for unfiltered builds', async () => {
runSpy.mockResolvedValue({
exitCode: 0,
signal: null,
stdout: '',
stderr: '',
})
await runTypeCheckCli({ baseDir, tsConfigPath, tscPath: 'tsc' })
expect(runSpy).toHaveBeenCalledWith(
expect.objectContaining({
args: expect.arrayContaining(['--project', tsConfigPath]),
})
)
expect(readdirSync(path.dirname(tsConfigPath))).toEqual([
'tsconfig.build.json',
])
})
it('distinguishes undefined and empty router selections and retains shared roots', () => {
const app = path.join(baseDir, 'app')
const pages = path.join(baseDir, 'pages')
const roots = [
path.join(app, 'page.tsx'),
path.join(pages, 'index.tsx'),
path.join(baseDir, 'app-other/shared.ts'),
]
expect(filterTypeScriptFiles(roots, { app, pages }, { app: [] })).toEqual(
roots.slice(1)
)
expect(filterTypeScriptFiles(roots, { app, pages }, { pages: [] })).toEqual(
[roots[0], roots[2]]
)
expect(
filterTypeScriptFiles(roots, { app, pages }, { app: [], pages: [] })
).toEqual([roots[2]])
})
})
...@@ -238,7 +238,11 @@ export async function getTypeScriptConfigurationCli({ ...@@ -238,7 +238,11 @@ export async function getTypeScriptConfigurationCli({
baseDir: string baseDir: string
tsConfigPath: string tsConfigPath: string
tscPath: string tscPath: string
}): Promise<{ compilerOptions: Record<string, any> }> { }): Promise<{
compilerOptions: Record<string, any>
files?: string[]
references?: { path: string }[]
}> {
const result = await runTypeScriptCli({ const result = await runTypeScriptCli({
cwd: baseDir, cwd: baseDir,
tscPath, tscPath,
......
...@@ -253,12 +253,6 @@ export async function verifyAndRunTypeScript({ ...@@ -253,12 +253,6 @@ export async function verifyAndRunTypeScript({
let result let result
if (shouldRunTypeCheck) { if (shouldRunTypeCheck) {
if (useTypeScriptCli) { if (useTypeScriptCli) {
if (debugBuildPaths) {
log.warn(
'`experimental.useTypeScriptCli` checks the complete TypeScript project; `--debug-build-paths` does not limit type checking.'
)
}
const { runTypeCheckCli } = const { runTypeCheckCli } =
require('./typescript/runTypeCheckCli') as typeof import('./typescript/runTypeCheckCli') require('./typescript/runTypeCheckCli') as typeof import('./typescript/runTypeCheckCli')
result = await runTypeCheckCli({ result = await runTypeCheckCli({
...@@ -266,6 +260,8 @@ export async function verifyAndRunTypeScript({ ...@@ -266,6 +260,8 @@ export async function verifyAndRunTypeScript({
tsConfigPath: resolvedTsConfigPath, tsConfigPath: resolvedTsConfigPath,
tscPath: typeScriptPath, tscPath: typeScriptPath,
cacheDir, cacheDir,
dirs: { app: appDir, pages: pagesDir },
debugBuildPaths,
onFirstOutput: onFirstCliOutput, onFirstOutput: onFirstCliOutput,
}) })
} else { } else {
......
...@@ -27,15 +27,20 @@ describe('TypeScript CLI backend', () => { ...@@ -27,15 +27,20 @@ describe('TypeScript CLI backend', () => {
}) })
let originalTsConfig: string let originalTsConfig: string
let originalPage: string
beforeAll(async () => { beforeAll(async () => {
originalTsConfig = await next.readFile('tsconfig.build.json') originalTsConfig = await next.readFile('tsconfig.build.json')
originalPage = await next.readFile('app/page.tsx')
}) })
afterEach(async () => { afterEach(async () => {
await next.patchFile('next.config.js', defaultConfig) await next.patchFile('next.config.js', defaultConfig)
await next.patchFile('tsconfig.build.json', originalTsConfig) await next.patchFile('tsconfig.build.json', originalTsConfig)
await next.deleteFile('src/type-error.ts').catch(() => {}) await next.deleteFile('src/type-error.ts').catch(() => {})
await next.deleteFile('app/with-type-error').catch(() => {})
await next.deleteFile('app/imported-error.ts').catch(() => {})
await next.patchFile('app/page.tsx', originalPage)
await next await next
.deleteFile('.next/dev/types/stale-type-error.test.ts') .deleteFile('.next/dev/types/stale-type-error.test.ts')
.catch(() => {}) .catch(() => {})
...@@ -100,23 +105,83 @@ describe('TypeScript CLI backend', () => { ...@@ -100,23 +105,83 @@ describe('TypeScript CLI backend', () => {
expect(result.cliOutput).toContain('Skipping validation of types') expect(result.cliOutput).toContain('Skipping validation of types')
}) })
it('checks the complete project with --debug-build-paths', async () => { it('checks dev types in unfiltered builds', async () => {
await next.patchFile( await next.patchFile(
'.next/dev/types/stale-type-error.test.ts', '.next/dev/types/stale-type-error.test.ts',
typeError typeError
) )
const result = await next.build()
expect(result.exitCode).toBe(1)
expect(result.cliOutput).toContain(
'.next/dev/types/stale-type-error.test.ts'
)
expect(result.cliOutput).toContain('error TS2322')
})
it('filters excluded routes without changing the custom tsconfig', async () => {
await next.patchFile(
'app/with-type-error/page.tsx',
typeError + '\nexport default function Page() { return null }\n'
)
const tsconfigBefore = JSON.parse(
await next.readFile('tsconfig.build.json')
)
const result = await next.build({ const result = await next.build({
args: ['--debug-build-paths', 'app/page.tsx'], args: ['--debug-build-paths', 'app/page.tsx'],
}) })
expect(result.exitCode).toBe(1) expect(result.exitCode).toBe(0)
expect(result.cliOutput).toContain( expect(result.cliOutput).not.toContain('does not limit type checking')
'`experimental.useTypeScriptCli` checks the complete TypeScript project; `--debug-build-paths` does not limit type checking.' const tsconfigAfter = JSON.parse(
await next.readFile('tsconfig.build.json')
) )
expect(result.cliOutput).toContain( expect(tsconfigAfter.files).toBeUndefined()
'.next/dev/types/stale-type-error.test.ts' expect(tsconfigAfter.include).toEqual(tsconfigBefore.include)
expect(tsconfigAfter.extends).toBe(tsconfigBefore.extends)
expect(await next.hasFile('.next/cache/.tsbuildinfo')).toBe(true)
})
it('reports errors in selected routes', async () => {
await next.patchFile(
'app/with-type-error/page.tsx',
typeError + '\nexport default function Page() { return null }\n'
)
const result = await next.build({
args: ['--debug-build-paths', 'app/with-type-error/page.tsx'],
})
expect(result.exitCode).toBe(1)
expect(result.cliOutput).toContain('app/with-type-error/page.tsx')
expect(result.cliOutput).toContain('error TS2322')
})
it('checks imports even when they are excluded as roots', async () => {
await next.patchFile('app/imported-error.ts', typeError)
await next.patchFile(
'app/page.tsx',
`import { invalidValue } from './imported-error'
export default function Page() { return <p>{invalidValue}</p> }
`
) )
const result = await next.build({
args: ['--debug-build-paths', 'app/page.tsx'],
})
expect(result.exitCode).toBe(1)
expect(result.cliOutput).toContain('app/imported-error.ts')
expect(result.cliOutput).toContain('error TS2322')
})
it('still checks shared files in filtered builds', async () => {
await next.patchFile('src/type-error.ts', typeError)
const result = await next.build({
args: ['--debug-build-paths', 'app/page.tsx'],
})
expect(result.exitCode).toBe(1)
expect(result.cliOutput).toContain('src/type-error.ts')
expect(result.cliOutput).toContain('error TS2322') expect(result.cliOutput).toContain('error TS2322')
}) })
}) })
...@@ -165,6 +230,19 @@ describe('TypeScript CLI backend', () => { ...@@ -165,6 +230,19 @@ describe('TypeScript CLI backend', () => {
expect(result.exitCode).toBe(0) expect(result.exitCode).toBe(0)
expect(await next.hasFile('.next/cache/.tsbuildinfo')).toBe(true) expect(await next.hasFile('.next/cache/.tsbuildinfo')).toBe(true)
}) })
it('filters roots with TypeScript 6 and inherited paths', async () => {
await next.patchFile(
'app/with-type-error/page.tsx',
typeError + '\nexport default function Page() { return null }\n'
)
const result = await next.build({
args: ['--debug-build-paths', 'app/page.tsx'],
})
expect(result.exitCode).toBe(0)
expect(await next.hasFile('.next/cache/.tsbuildinfo')).toBe(true)
})
}) })
// This suite controls the local build lifecycle directly, which deployment tests cannot reproduce. // This suite controls the local build lifecycle directly, which deployment tests cannot reproduce.
......
...@@ -321,7 +321,7 @@ describe('debug-build-paths', () => { ...@@ -321,7 +321,7 @@ describe('debug-build-paths', () => {
}) })
// Build should fail due to type error in with-type-error/page.tsx // Build should fail due to type error in with-type-error/page.tsx
expect(buildResult.exitCode).toBe(1) expect(buildResult.exitCode).toBe(1)
expect(buildResult.cliOutput).toContain('Type error') expect(buildResult.cliOutput).toContain('error TS2322')
expect(buildResult.cliOutput).toContain('with-type-error/page.tsx') expect(buildResult.cliOutput).toContain('with-type-error/page.tsx')
}) })
}) })
......
/** @type {import('next').NextConfig} */ /** @type {import('next').NextConfig} */
const nextConfig = { const nextConfig = {}
experimental: {
useTypeScriptCli: false,
},
}
module.exports = nextConfig module.exports = nextConfig
/** @type {import('next').NextConfig} */ /** @type {import('next').NextConfig} */
const nextConfig = { const nextConfig = {}
experimental: {
useTypeScriptCli: false,
},
}
module.exports = nextConfig module.exports = nextConfig
/** @type {import('next').NextConfig} */ /** @type {import('next').NextConfig} */
const nextConfig = { const nextConfig = {}
experimental: {
useTypeScriptCli: false,
},
}
module.exports = nextConfig module.exports = nextConfig
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment