Skip to content

Commit 6952b51

Browse files
committed
update some
1 parent f9efd9f commit 6952b51

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

docs/01-app/03-api-reference/05-config/02-typescript.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Next.js generates global helpers for App Router route types. These are available
8282

8383
## Examples
8484

85-
### Type checking Next.js Configuration files
85+
### Type Checking Next.js Configuration Files
8686

8787
You can use TypeScript and import types in your Next.js configuration by using `next.config.ts`.
8888

@@ -96,7 +96,7 @@ const nextConfig: NextConfig = {
9696
export default nextConfig
9797
```
9898

99-
Module resolution in `next.config.ts` is currently limited to CommonJS. However, ECMAScript Modules syntax is available when [using Node.js native TypeScript resolver](#using-nodejs-native-typescript-resolver-for-nextconfigts) for Node.js v22.10.0 and higher.
99+
Module resolution in `next.config.ts` is currently limited to CommonJS. However, ECMAScript Modules (ESM) syntax is available when [using Node.js native TypeScript resolver](#using-nodejs-native-typescript-resolver-for-nextconfigts) for Node.js v22.10.0 and higher.
100100

101101
When using the `next.config.js` file, you can add some type checking in your IDE using JSDoc as below:
102102

@@ -113,17 +113,17 @@ module.exports = nextConfig
113113

114114
### Using Node.js Native TypeScript Resolver for `next.config.ts`
115115

116-
> **Note**: Resolving `next.config.ts` using Node.js native TypeScript resolver is available for Node.js v22.10.0 and higher, and only when the feature is enabled. Next.js does not enable the feature by default.
116+
> **Note**: Using Node.js native TypeScript resolver for `next.config.ts` is available for Node.js v22.10.0 and higher, and only when the feature is enabled. Next.js does not enable the feature by default.
117117
118-
Next.js feature detects [Node.js native TypeScript resolver](https://nodejs.org/api/typescript.html) by [`process.features.typescript`](https://nodejs.org/api/process.html#processfeaturestypescript) which was added in Node.js v22.10.0. This allows `next.config.ts` to use native ECMAScript Modules syntax like top-level `await` and dynamic imports in `next.config.ts`. However, it inherits the limitations of the Node.js native TypeScript resolver.
118+
Next.js feature detects [Node.js native TypeScript resolver](https://nodejs.org/api/typescript.html) by [`process.features.typescript`](https://nodejs.org/api/process.html#processfeaturestypescript) which was added in Node.js v22.10.0. This allows `next.config.ts` to use native ECMAScript Modules (ESM) syntax like top-level `await` and dynamic imports in `next.config.ts`. However, it inherits the limitations of the Node.js native TypeScript resolver.
119119

120-
For Node.js below v23.6.0, you need to run `next dev` with `NODE_OPTIONS=--experimental-transform-types` flag to enable the Node.js native TypeScript resolver:
120+
Node.js enables the feature by default since [v22.18.0](https://nodejs.org/en/blog/release/v22.18.0). For versions below v22.18.0, you need to run `next dev` with `NODE_OPTIONS=--experimental-transform-types` flag to enable the Node.js native TypeScript resolver:
121121

122122
```bash
123123
NODE_OPTIONS=--experimental-transform-types next <command>
124124
```
125125

126-
Although `next.config.ts` supports native ECMAScript Modules syntax on CommonJS projects, Node.js will still assume `next.config.ts` is a CommonJS file by default, resulting in Node.js reparsing the file as ECMAScript Modules when module syntax is detected. Therefore, we recommend using the `next.config.mts` file for CommonJS projects.
126+
Although `next.config.ts` supports native ESM syntax on CommonJS projects, Node.js will still assume `next.config.ts` is a CommonJS file by default, resulting in Node.js reparsing the file as ESM when module syntax is detected. Therefore, we recommend using the `next.config.mts` file for CommonJS projects.
127127

128128
```ts filename="next.config.mts"
129129
import type { NextConfig } from 'next'

0 commit comments

Comments
 (0)