-
Notifications
You must be signed in to change notification settings - Fork 30k
Add gitignore note for next-env.d.ts #86809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add gitignore note for next-env.d.ts #86809
Conversation
Co-authored-by: joseph.chamochumbi <[email protected]>
|
Cursor Agent can help with this pull request. Just |
| | [`.env.development`](/docs/app/guides/environment-variables) | Development environment variables | | ||
| | [`eslint.config.mjs`](/docs/app/api-reference/config/eslint) | Configuration file for ESLint | | ||
| | `.gitignore` | Git files and folders to ignore | | ||
| | `next-env.d.ts` | TypeScript declaration file for Next.js | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.env* files should also not be tracked
|
Hey, I just came across this PR because I was wondering if this file should be tracked by version control. I ultimately decided to track it because I saw this 4 years old comment in a GH issue by one Next.js core team member: #26533 (comment) Can you please explain me why it shouldn't be tracked? Its content almost never changes, so it seems reasonable, for me, to track it. |
|
It is a recommendation after all, but do consider that, Next.js can publish and update type signatures on that file. For example with the introduction of https://nextjs.org/docs/app/api-reference/config/next-config-js/isolatedDevBuild, or route props helpers, etc.
|
…s-claude-4.5-sonnet-thinking-645b
|
@icyJoseph I was not sure where to put this :/ so I post it here. The problem I encountered was that with Next.js 16, when adding a static image (using an import), linting in ci would start failing. The problem with ci was that next-env.d.ts did not exist, because it did not exist typescript would not have access to next/image-types/global, and ended up throwing an error. So instead of just running linting and then build, you actually need to run "next typegen", then linting and finally build. I am not sure this is due to the fact that next.js 16 does not handle linting during builds on its own anymore or because of the new isolatedDevBuild!? I am glad I found your comment here #85738 (comment) else I would not have known about the next typegen command. When I asked the AI it either removed the next-env.d.ts from .gitignore (bad) or it create a new types file that containing similar types to what is in next/image-types/global and then add them to tsconfig (bad). I have a feeling other users will run into this, so maybe a docs update would be good? Maybe in here https://nextjs.org/docs/app/getting-started/installation#set-up-linting? |
|
@chrisweb we do mention here, https://nextjs.org/docs/app/api-reference/cli/next#next-typegen-options:
That being said, yes, we need to improve discoverability of this.
I'll add more signposts to discover |
Yes, that would be great 👍 @icyJoseph (and now that I have already misused this PR, I just wanted to say thank you for the many useful posts and comments I have read from you over the years, they helped me countless times :) ) |
Slack Thread