Skip to content

docs(repo): Document next-env.d.ts behavior and restore workflow#16944

Merged
sfanahata merged 6 commits intomasterfrom
chore/gitignore-next-env-d-ts
Mar 13, 2026
Merged

docs(repo): Document next-env.d.ts behavior and restore workflow#16944
sfanahata merged 6 commits intomasterfrom
chore/gitignore-next-env-d-ts

Conversation

@sfanahata
Copy link
Contributor

@sfanahata sfanahata commented Mar 13, 2026

Problem
Every time next.js wants to update next-env.d.ts on pnpm dev or pnpm 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.ts shows 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.ts to .gitignore so the same behavior is available for everyone.

  • Added new CI rule to run typegen be fore running the type-check so that next-env.d.ts is 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.

    • Reason: next-env.d.ts is in .gitignore, so it isn’t in the repo. The lint job only runs install and then pnpm lint:ts (type-check). TypeScript expects next-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.

  • Urgent deadline (GA date, etc.):
  • Other deadline:
  • None: Not urgent, can wait up to 1 week+

SLA

  • Teamwork makes the dream work, so please add a reviewer to your PRs.
  • Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it.
    Thanks in advance for your help!

PRE-MERGE CHECKLIST

Make sure you've checked the following before merging your changes:

  • Checked Vercel preview for correctness, including links
  • PR was reviewed and approved by any necessary SMEs (subject matter experts)
  • PR was reviewed and approved by a member of the Sentry docs team

Shannon Anahata added 2 commits March 13, 2026 15:18
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
@vercel
Copy link

vercel bot commented Mar 13, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
develop-docs Ready Ready Preview, Comment Mar 13, 2026 11:42pm
sentry-docs Ready Ready Preview, Comment Mar 13, 2026 11:42pm

Request Review

- 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
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

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

Create PR

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
Copy link
Member

@sergical sergical left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it only the test workflow we need this in? nothing in the build / dev commands?

@sfanahata
Copy link
Contributor Author

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.

@sfanahata sfanahata merged commit c5c916e into master Mar 13, 2026
20 checks passed
@sfanahata sfanahata deleted the chore/gitignore-next-env-d-ts branch March 13, 2026 23:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants