Skip to content

typescript

Source URL: https://nextjs.org/docs/app/api-reference/config/next-config-js/typescript

Configure TypeScript behavior with the typescript option in next.config.js:

module.exports = {
typescript: {
ignoreBuildErrors: false,
tsconfigPath: 'tsconfig.json',
},
}
OptionTypeDefaultDescription
ignoreBuildErrorsbooleanfalseAllow production builds to complete even with TypeScript errors.
tsconfigPathstring'tsconfig.json'Path to a custom tsconfig.json file.

Next.js fails your production build (next build) when TypeScript errors are present in your project.

If you’d like Next.js to dangerously produce production code even when your application has errors, you can disable the built-in type checking step.

If disabled, be sure you are running type checks as part of your build or deploy process, otherwise this can be very dangerous.

module.exports = {
typescript: {
// !! WARN !!
// Dangerously allow production builds to successfully complete even if
// your project has type errors.
// !! WARN !!
ignoreBuildErrors: true,
},
}

Use a different TypeScript configuration file for builds or tooling:

module.exports = {
typescript: {
tsconfigPath: 'tsconfig.build.json',
},
}