Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs to show how to typecheck next.config.js #25240

Merged
merged 5 commits into from
May 20, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions docs/basic-features/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,23 @@ Next.js automatically supports the `tsconfig.json` `"paths"` and `"baseUrl"` opt

You can learn more about this feature on the [Module Path aliases documentation](/docs/advanced-features/module-path-aliases.md).

## Type checking next.config.js

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:

```js
// @ts-check

/**
* @type {import('next/dist/next-server/server/config').NextConfig}
**/
const nextConfig = {
/* config options here */
}

module.exports = nextConfig
```

## Incremental type checking

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.
Expand Down