主题
typescript
使用 next.config.js 中的 typescript 选项配置 TypeScript 行为:
¥Configure TypeScript behavior with the typescript option in next.config.js:
选项
¥Options
| 选项 | 类型 | 默认 | 描述 |
|---|---|---|---|
ignoreBuildErrors | boolean | false | 即使存在 TypeScript 错误,也允许生产环境构建完成。 |
tsconfigPath | string | 'tsconfig.json' | 自定义 tsconfig.json 文件的路径。 |
ignoreBuildErrors
当项目中存在 TypeScript 错误时,Next.js 会导致生产构建失败 (next build)。
¥Next.js fails your production build (next build) when TypeScript errors are present in your project.
如果你希望 Next.js 即使你的应用有错误也能危险地生成生产代码,你可以禁用内置类型检查步骤。
¥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.
tsconfigPath
为构建或工具使用不同的 TypeScript 配置文件:
¥Use a different TypeScript configuration file for builds or tooling:
请参阅 TypeScript 配置 页面了解更多详情。
¥See the TypeScript configuration page for more details.