next dev
rewrites tsconfig.json
when it shouldn't
#39942
Replies: 25 comments 32 replies
-
Currently, overwriting the Do you have any specific properties/configurations that do not want to be overwritten by Next.js? |
Beta Was this translation helpful? Give feedback.
-
This sounds like a broader ask/feature request, rather than an addressable bug, but if you have a reproduction where any of the Next.js configured options is causing a bug in your application, please let us know. |
Beta Was this translation helpful? Give feedback.
-
Yeah this is really annoying, next js keeps adding strictNullChecks even when I have it in the base .tsconfig. I should be able to turn off nextjs' ability to modify the tsconfig. I'm happy with all the options nextjs needs to setup, but if it can't recognize them being present in the base config I'm importing via |
Beta Was this translation helpful? Give feedback.
-
In my case, next.js keeps adding |
Beta Was this translation helpful? Give feedback.
-
+1 for respecting the prettier & / or eslint configs if the framework overwrites config files. |
Beta Was this translation helpful? Give feedback.
-
I spend hours to understand why nextjs modifies my tsconfigs in a multi workspace project, but had to give up. |
Beta Was this translation helpful? Give feedback.
-
Hello guys, |
Beta Was this translation helpful? Give feedback.
-
Related issue: #19155 which is very annoying. Please do not overwrite tsconfig, or at least let us opt out... |
Beta Was this translation helpful? Give feedback.
-
+1 really annoying, there should be an option to stop that already now? |
Beta Was this translation helpful? Give feedback.
-
I have a situation where I'm using NX and this stops me from being able to use both storybook and the app router. All this needs is to issue a warning and have an argument to auto-fix. Then we could have fixed it manually in the correct config (which you didn't find). This is frustrating, undesirable behavior not connected with functionality. Please stop deciding for others what data files on their computers should contain. |
Beta Was this translation helpful? Give feedback.
-
Anyone found a workaround? Iam using NX and since this happens, i cant do a successful deploy with app dir. It changes my tsconfig on deployment :( |
Beta Was this translation helpful? Give feedback.
-
ughh. should have just stuck with Vite |
Beta Was this translation helpful? Give feedback.
-
Hey @leerob and team! Why isn't this fixed yet? I specifically do not want a "lib" section in my
I'll quote https://www.typescriptlang.org/tsconfig#target:
|
Beta Was this translation helpful? Give feedback.
-
In my opinion, it is pretty short-sighted to not have an option to turn this off. I understand and can appreciate tools that make it easy to get started, however when your configurations grow to be more complex, you need a way to regain total control over your configuration files. My use case is, in a monorepo, all packages are structured in the same way. My frontend apps have the following tsconfig files:
The tsconfig file marked as being overwritten above contains the following:
Having warnings during |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
This comment was marked as off-topic.
This comment was marked as off-topic.
-
very strange/undesirable behavior to automatically add i am going to patch our version of next.js to not do this, but next.js should have this only as an opt-in, or at the very least, offer an opt-out. this increases the coupling between next.js and TS as well so any breaking changes to TS could break next.js. |
Beta Was this translation helpful? Give feedback.
-
I am trying to use next.js with https://github.com/aspect-build/rules_js in Bazel.
|
Beta Was this translation helpful? Give feedback.
-
Could someone please document what's the minimal content of tsconfig file which will prevent next from modifying it? Thanks! |
Beta Was this translation helpful? Give feedback.
-
Here is an updated patch for 14.2.5 that supports only disabling tsconfig rewriting after the first setup. https://gist.github.com/vinnymac/efa90137f8c7026490c4b19f8ab73286 |
Beta Was this translation helpful? Give feedback.
-
For anyone else struggling with this, I came across this issue when using a composite tsconfig with separate configs for test and non-test files. Adding the following to my
|
Beta Was this translation helpful? Give feedback.
-
Thank you @vinnycodes! I'll second this as the go-to fix for this frankly asinine, lazy hack that doesn't really deserve the distinction of being called a feature. I really, really wish @TzviPM's fix would've worked out because the less you have to touch someone else's code, the better, but Next.js now unfortunately overrides tsconfig.json outright! =/ Serious question for the maintainers behind this: Assuming for the sake of argument that there are certain devs who constantly bother you ad nauseam with stupid questions and complaints about how they can't get their TS config to work with Next.js (which is understandably annoying after a certain point, I'll grant that), don't you think that perhaps updating your docs, publishing a tutorial on your blog, providing a standard TS config for everyone to opt into at their leisure, and then pointing everyone towards those resources would've been the saner choice? Worse yet, what's stopping you from choosing to modify other files in an app workspace with a hard-coded approach if you think this is justifiable? Literally everyone else in the open source community informs their users about how to do things the "right" way or in an ideal way to get things to work WITHOUT FORCING THEM by default to do things one way or the other. If they can't hack it, it's on them. Don't make the rest of us suffer just because somebody else can't bother to figure it out, please! |
Beta Was this translation helpful? Give feedback.
-
This is still an issue. Im just "excluding" whatever Also, I would love to understand why If anything, it should just be its own one off command used in the |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Hey y'all, sorry we haven't replied with more details here. I'll surface this to our team and we can take a look. I don't have a timeline for a fix I can commit to, but wanted to let you know we hear you here. Best way to help us prioritize is to update the main message, as we frequently sort by top upvotes when planning and prioritizing. Please refrain from throwing +1 like messages on the thread without more context or details, as it sends unnecessary notifications to the group and will not help with prioritization. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Verify canary release
Provide environment information
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
Next.js rewrites
tsconfig.json
even when it doesn't need to. In the reproduction repo it's adding"exclude": ["node_modules"]
, even thoughnode_modules
directory is covered by the default ofexclude
(see https://www.typescriptlang.org/tsconfig#exclude). There are other similar situations when Next.js thinks it's smarter than me and changestsconfig.json
, but they are not included in the reproduction repo because it is not relevant to the proposed solution.Also, when making those edits, Next.js doesn't respect Prettier config.
This is
tsconfig.json
from the reproduction repo:This is
tsconfig.json
after following the steps to reproduce the bug:Expected Behavior
Next.js never touches
tsconfig.json
. It can print warnings, but I should be able to turn them off.Link to reproduction
https://github.com/jakubmazanec/nextjs-tsconfig-bug
To Reproduce
npm install
npm run dev
tsconfig.json
Beta Was this translation helpful? Give feedback.
All reactions