#Typescript error in monorepo
1 messages · Page 1 of 1 (latest)
Based on the information provided in the knowledge sources, it seems like you're encountering TypeScript errors in your Next.js project within a monorepo structure.
One of the common issues with TypeScript in Next.js is that the production build (next build) fails when TypeScript errors are present in your project. Next.js has a built-in type checking step that can be disabled if you want your production build to complete even when your application has errors. However, this can be dangerous if you're not running type checks as part of your build or deploy process.
Here's how you can disable the built-in type checking step in your next.config.js:
module.exports = {
typescript: {
// !! WARN !!
// Dangerously allow production builds to successfully complete even if
// your project has type errors.
// !! WARN !!
ignoreBuildErrors: true,
},
}
(Source: Next.js Docs (https://nextjs.org/docs/pages/api-reference/next-config-js/typescript))
However, it's recommended to use TypeScript and the TypeScript plugin for better type-safety, and to help you catch errors early.
If you're still encountering issues, it might be helpful to look at similar issues reported in the Next.js GitHub repository, such as this one (https://github.com/vercel/next.js/issues/55080), to see if any of the solutions or workarounds suggested there apply to your situation.
Remember, it's always important to ensure that your TypeScript configuration is set up correctly, especially in a monorepo setup.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
Let me check the knowledge base for you. One moment! :books:
If you don't want to ignore TypeScript errors and you're still encountering them, it's likely that there are issues with your TypeScript configuration or the way your monorepo is set up.
Here are a few things you could check:
-
TypeScript Configuration: Make sure your
tsconfig.jsonis correctly set up. For example, you should have"jsx": "preserve"or"jsx": "react"in yourcompilerOptions. This could be the reason why you're seeing errors like "Cannot use JSX unless the '--jsx' flag is provided". -
Monorepo Setup: In a monorepo setup, it's important to ensure that all dependencies are correctly linked and that TypeScript is correctly configured to include all relevant packages in the type checking process.
-
Incremental Type Checking: Since
v10.2.1, Next.js supports incremental type checking. This can help speed up type checking in larger applications. You can enable this in yourtsconfig.json. (Source (https://nextjs.org/docs/app/building-your-application/configuring/typescript#incremental-type-checking)) -
Linting: If you're using ESLint, make sure it's correctly configured. Next.js fails your production build when ESLint errors are present. You can disable this behavior, but it's not recommended unless you have ESLint configured to run in a separate part of your workflow. (Source (https://nextjs.org/docs/app/api-reference/next-config-js/eslint))