docs(repo): Document next-env.d.ts behavior and restore workflow#16944
docs(repo): Document next-env.d.ts behavior and restore workflow#16944
Conversation
Explain why next-env.d.ts often shows as modified (Next.js regenerates it), that 'git restore next-env.d.ts' is safe, and how it differs from lockfiles. Add long-term note: once the repo upgrades to Next 15.5+, add next-env.d.ts to .gitignore and run 'next typegen' before type-check for the recommended approach; current Next 15.1.x does not expose the typegen CLI. Made-with: Cursor
File is auto-generated by Next.js on pnpm dev / pnpm build. Ignoring it prevents local churn; everyone gets the same .gitignore via this PR. Made-with: Cursor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
- Add pnpm next build before lint:ts in test workflow so type-check passes when next-env.d.ts is gitignored. Replace with next typegen on Next 15.5+. - Shorten next-env.d.ts messaging in AGENTS.md and CONTRIBUTING.md. Made-with: Cursor
Allow next build to run in GitHub Actions without a DSN so we can generate next-env.d.ts for type-check. Production and local builds still require the env. Made-with: Cursor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix prepared fixes for both issues found in the latest run.
- ✅ Fixed: CI build step will fail, blocking type-check
- Replaced 'pnpm next build' with 'pnpm next typegen' to generate type definitions without running a full build that requires doctree.json
- ✅ Fixed: Sentry DSN validation weakened for all CI workflows
- Changed bypass check from GITHUB_ACTIONS to NEXT_TYPEGEN to narrow the scope to only the typegen step, preserving validation for production builds
Or push these changes by commenting:
@cursor push aedfc55282
Preview (aedfc55282)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -40,8 +40,10 @@
- run: pnpm install --frozen-lockfile
- # Generate next-env.d.ts (in .gitignore); required before type-check. Replace with `next typegen` when on Next 15.5+
- - run: pnpm next build
+ # Generate next-env.d.ts (in .gitignore); required before type-check
+ - run: pnpm next typegen
+ env:
+ NEXT_TYPEGEN: 'true'
# Additional checks
- run: pnpm lint:ts
diff --git a/next.config.ts b/next.config.ts
--- a/next.config.ts
+++ b/next.config.ts
@@ -90,7 +90,7 @@
if (
process.env.NODE_ENV !== 'development' &&
!process.env.NEXT_PUBLIC_SENTRY_DSN &&
- !process.env.GITHUB_ACTIONS
+ !process.env.NEXT_TYPEGEN
) {
throw new Error(
'Missing required environment variable: NEXT_PUBLIC_SENTRY_DSN must be set in production'This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.
…TYPEGEN - Run enforce-redirects and generate-doctree before next build so CI build succeeds (doctree.json required for sitemap). typegen not available in current Next. - Bypass DSN check only when NEXT_TYPEGEN is set (typegen/build step), not all GITHUB_ACTIONS, so other workflows still validate Sentry config. Made-with: Cursor
Generates type definitions only; no doctree or full build. Repo is on Next 15.5. Made-with: Cursor
sergical
left a comment
There was a problem hiding this comment.
is it only the test workflow we need this in? nothing in the build / dev commands?
Correct. Basically, those build steps automatically run through getting that file as a part of its process, so they're fine. From my bot friend: The test workflow is different: it only runs pnpm install and then pnpm lint:ts (tsc). It never runs build or dev, so the file wouldn’t exist unless we add a step. We added pnpm next typegen there so tsc has the file without doing a full build. |


Problem
Every time next.js wants to update
next-env.d.tsonpnpm devorpnpm build, it shows up in the branch's commits.Solution
.gitignore the file and add a new CI rule so that no one has to deal with this manually.
Added an explanation to agents.md and contributing.md why
next-env.d.tsshows as modified when Next.js regenerates it, and why it's in.gitignore, as well as future state once we upgrade.Added
next-env.d.tsto.gitignoreso the same behavior is available for everyone.Added new CI rule to run
typegenbe fore running the type-check so thatnext-env.d.tsis added into the check.In .github/workflows/test.yml, in the Lint job, added a step before pnpm lint:ts: Step: Run pnpm next build.
next-env.d.tsis in.gitignore, so it isn’t in the repo. The lint job only runsinstalland thenpnpm lint:ts(type-check). TypeScript expectsnext-env.d.ts(it’s in tsconfig include), so without it the type-check would fail.IS YOUR CHANGE URGENT?
Help us prioritize incoming PRs by letting us know when the change needs to go live.
SLA
Thanks in advance for your help!
PRE-MERGE CHECKLIST
Make sure you've checked the following before merging your changes: