You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/01-app/01-getting-started/02-project-structure.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,7 +44,7 @@ Top-level files are used to configure your application, manage dependencies, run
44
44
|[`.env.development`](/docs/app/guides/environment-variables)| Development environment variables (should not be tracked by version control) |
45
45
|[`eslint.config.mjs`](/docs/app/api-reference/config/eslint)| Configuration file for ESLint |
46
46
|`.gitignore`| Git files and folders to ignore |
47
-
|`next-env.d.ts`| TypeScript declaration file for Next.js (should not be tracked by version control) |
47
+
|[`next-env.d.ts`](/docs/app/api-reference/config/typescript#next-envdts)| TypeScript declaration file for Next.js (should not be tracked by version control) |
48
48
|`tsconfig.json`| Configuration file for TypeScript |
49
49
|`jsconfig.json`| Configuration file for JavaScript |
Copy file name to clipboardExpand all lines: docs/01-app/03-api-reference/05-config/01-next-config-js/typescript.mdx
+35-3Lines changed: 35 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,36 @@
1
1
---
2
2
title: typescript
3
-
description: Next.js reports TypeScript errors by default. Learn to opt-out of this behavior here.
3
+
description: Configure how Next.js handles TypeScript errors during production builds and specify a custom tsconfig file.
4
4
---
5
5
6
6
{/* The content of this doc is shared between the app and pages router. You can use the `<PagesOnly>Content</PagesOnly>` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */}
7
7
8
+
Configure TypeScript behavior with the `typescript` option in `next.config.js`:
Copy file name to clipboardExpand all lines: docs/01-app/03-api-reference/05-config/02-typescript.mdx
+12-1Lines changed: 12 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -80,6 +80,17 @@ Next.js generates global helpers for App Router route types. These are available
80
80
81
81
</AppOnly>
82
82
83
+
## `next-env.d.ts`
84
+
85
+
Next.js generates a `next-env.d.ts` file in your project root. This file references Next.js type definitions, allowing TypeScript to recognize non-code imports (images, stylesheets, etc.) and Next.js-specific types.
86
+
87
+
Running `next dev`, `next build`, or [`next typegen`](/docs/app/api-reference/cli/next#next-typegen-options) regenerates this file.
88
+
89
+
> **Good to know**:
90
+
>
91
+
> - We recommend adding `next-env.d.ts` to your `.gitignore` file.
92
+
> - The file must be in your `tsconfig.json``include` array (`create-next-app` does this automatically).
93
+
83
94
## Examples
84
95
85
96
### Type Checking Next.js Configuration Files
@@ -470,7 +481,7 @@ If you'd like Next.js to dangerously produce production code even when your appl
0 commit comments