跳到內容

typescript

當您的專案中存在 TypeScript 錯誤時,Next.js 會導致您的生產構建next build)失敗。

如果您希望 Next.js 即使在應用程式存在錯誤的情況下也危險地生成生產程式碼,您可以停用內建的型別檢查步驟。

如果停用,請務必在構建或部署過程中執行型別檢查,否則這可能非常危險。

開啟 next.config.js 並在 typescript 配置中啟用 ignoreBuildErrors 選項

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