diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 31b9478ca7f354..c5b55e19b949a7 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -40,6 +40,11 @@ jobs:
- run: pnpm install --frozen-lockfile
+ # 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/.gitignore b/.gitignore
index 87bf346528193a..8763df8b47941c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -73,6 +73,7 @@ linkcheck
# next.js
/.next/
/out/
+next-env.d.ts
public/~partytown
public/page-data
diff --git a/AGENTS.md b/AGENTS.md
index ebc63ce7ca7b3e..cdfde89f3df8c3 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -52,6 +52,10 @@ Run `pnpm test` for vitest. Tests live alongside source files or in `__tests__`
| `pnpm lint:eslint` | ESLint check |
| `pnpm lint:prettier` | Prettier check |
+## Repo UX / Generated files
+
+`next-env.d.ts` is in `.gitignore` and is generated by Next.js when you run `pnpm dev` or `pnpm build`. When we upgrade to Next 15.5+, we can run `next typegen` in CI and in `lint:ts` so the file is generated before type-check.
+
## Developer Documentation (develop-docs/)
When writing requirements in `develop-docs/`:
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 6818dc5e118e1c..d7943a39b3d816 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -19,3 +19,5 @@ pnpm dev:developer-docs
```
With that, the repo is fully set up and you are ready to open local docs under http://localhost:3000
+
+`next-env.d.ts` is in `.gitignore` and is generated when you run `pnpm dev` or `pnpm build`. When we upgrade to Next 15.5+, we can run `next typegen` in CI and in `lint:ts` so the file is generated before type-check.
diff --git a/next-env.d.ts b/next-env.d.ts
deleted file mode 100644
index 36a4fe488ad024..00000000000000
--- a/next-env.d.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-///
-///
-///
-///
-
-// NOTE: This file should not be edited
-// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
diff --git a/next.config.ts b/next.config.ts
index 32aa844901692f..9b53988f208e8d 100644
--- a/next.config.ts
+++ b/next.config.ts
@@ -87,7 +87,11 @@ const outputFileTracingIncludes = process.env.NEXT_PUBLIC_DEVELOPER_DOCS
'sitemap.xml': ['public/doctree.json'],
};
-if (process.env.NODE_ENV !== 'development' && !process.env.NEXT_PUBLIC_SENTRY_DSN) {
+if (
+ process.env.NODE_ENV !== 'development' &&
+ !process.env.NEXT_PUBLIC_SENTRY_DSN &&
+ !process.env.NEXT_TYPEGEN
+) {
throw new Error(
'Missing required environment variable: NEXT_PUBLIC_SENTRY_DSN must be set in production'
);