Skip to content

Commit 14cedc7

Browse files
authored
Update docs to show how to typecheck next.config.js (#25240)
## Documentation Partially resolves #5318 - [x] Make sure the linting passes
1 parent 24c3929 commit 14cedc7

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

docs/basic-features/typescript.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,23 @@ Next.js automatically supports the `tsconfig.json` `"paths"` and `"baseUrl"` opt
128128
129129
You can learn more about this feature on the [Module Path aliases documentation](/docs/advanced-features/module-path-aliases.md).
130130
131+
## Type checking next.config.js
132+
133+
The `next.config.js` file must be a JavaScript file as it does not get parsed by Babel or TypeScript, however you can add some type checking in your IDE using JSDoc as below:
134+
135+
```js
136+
// @ts-check
137+
138+
/**
139+
* @type {import('next/dist/next-server/server/config').NextConfig}
140+
**/
141+
const nextConfig = {
142+
/* config options here */
143+
}
144+
145+
module.exports = nextConfig
146+
```
147+
131148
## Incremental type checking
132149
133150
Since `v10.2.1` Next.js supports [incremental type checking](https://www.typescriptlang.org/tsconfig#incremental) when enabled in your `tsconfig.json`, this can help speed up type checking in larger applications.

0 commit comments

Comments
 (0)