Skip to content

Commit 3a44c24

Browse files
docs: typegen next-env.d.ts feedback (#85273)
Bringing back some info lost when next lint was removed, and accounting for `isolatedDevBuild` in v16 --------- Co-authored-by: Ismael <ismael@vercel.com>
1 parent 90a3b82 commit 3a44c24

File tree

1 file changed

+7
-1
lines changed
  • docs/01-app/03-api-reference/06-cli

1 file changed

+7
-1
lines changed

docs/01-app/03-api-reference/06-cli/next.mdx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,20 @@ The following options are available for the `next typegen` command:
170170
| `-h, --help` | Show all available options. |
171171
| `[directory]` | A directory on which to generate types. If not provided, the current directory will be used. |
172172

173-
Output files are written to `<distDir>/types` (default: `.next/types`):
173+
Output files are written to `<distDir>/types` (typically: `.next/dev/types` or `.next/types`, see [`isolatedDevBuild`](/docs/app/api-reference/config/next-config-js/isolatedDevBuild)):
174174

175175
```bash filename="Terminal"
176176
next typegen
177177
# or for a specific app
178178
next typegen ./apps/web
179179
```
180180

181+
Additionally, `next typegen` generates a `next-env.d.ts` file. We recommend adding `next-env.d.ts` to your `.gitignore` file.
182+
183+
The `next-env.d.ts` file is included into your `tsconfig.json` file, to make Next.js types available to your project.
184+
185+
To ensure `next-env.d.ts` is present before type-checking run `next typegen`. The commands `next dev` and `next build` also generate the `next-env.d.ts` file, but it is often undesirable to run these just to type-check, for example in CI/CD environments.
186+
181187
> **Good to know**: `next typegen` loads your Next.js config (`next.config.js`, `next.config.mjs`, or `next.config.ts`) using the production build phase. Ensure any required environment variables and dependencies are available so the config can load correctly.
182188
183189
## Examples

0 commit comments

Comments
 (0)