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
{{ message }}
Repository navigation
Commit cbf0cef
Browse filesBrowse the repository at this point in the historyBrowse files
## Summary
Enable the project-local TypeScript CLI checker by default during `next
build`, while preserving `experimental.useTypeScriptCli: false` as an
opt-out to the TypeScript compiler API. Update the TypeScript 7
guidance, diagnostics, tests, and documentation to match the new
default.
## Verification
- `pnpm exec jest --runTestsByPath test/unit/isolated/config.test.ts`
- Pre-commit lint-staged checks passed (Prettier and ESLint)
- Not run: `pnpm test-start-turbo
test/production/app-dir/typescript-cli/typescript-cli.test.ts` (isolated
fixture dependency installation was blocked by unavailable npm registry
access)
- Not run: `pnpm --filter=next types` (repository has pre-existing
unrelated TypeScript errors)
<!-- NEXT_JS_LLM -->
Copy file name to clipboardExpand all lines: docs/01-app/03-api-reference/05-config/01-next-config-js/useTypeScriptCli.mdx
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ description: Run the project-local TypeScript CLI for type checking during produ
4
4
version: experimental
5
5
---
6
6
7
-
The `experimental.useTypeScriptCli` option makes `next build`run the project-local `tsc` command instead of loading the TypeScript JavaScript compiler API. You can use this option with TypeScript 6, and it enables [TypeScript 7](https://devblogs.microsoft.com/typescript/announcing-typescript-7-0/) support while its JavaScript API is unavailable.
7
+
By default, `next build`runs the project-local `tsc` command instead of loading the TypeScript JavaScript compiler API. This supports TypeScript 6 and enables [TypeScript 7](https://devblogs.microsoft.com/typescript/announcing-typescript-7-0/) while its JavaScript API is unavailable.
8
8
9
9
Install TypeScript 7 in your project:
10
10
@@ -24,14 +24,14 @@ yarn add -D typescript@^7
24
24
bun add -D typescript@^7
25
25
```
26
26
27
-
Then, explicitly enable the CLI checker:
27
+
The CLI checker is enabled by default. To use the TypeScript JavaScript compiler API instead, set `experimental.useTypeScriptCli` to `false`:
28
28
29
29
```ts filename="next.config.ts" switcher
30
30
importtype { NextConfig } from'next'
31
31
32
32
const nextConfig:NextConfig= {
33
33
experimental: {
34
-
useTypeScriptCli: true,
34
+
useTypeScriptCli: false,
35
35
},
36
36
}
37
37
@@ -42,14 +42,14 @@ export default nextConfig
42
42
/**@type{import('next').NextConfig}*/
43
43
constnextConfig= {
44
44
experimental: {
45
-
useTypeScriptCli:true,
45
+
useTypeScriptCli:false,
46
46
},
47
47
}
48
48
49
49
module.exports= nextConfig
50
50
```
51
51
52
-
Next.js does not select the CLI checker automatically. If TypeScript 7 is installed without this option, `next build` exits with instructions to enable it or install a TypeScript version supported by the default checker.
52
+
If you opt out while using TypeScript 7, `next build` exits because the TypeScript JavaScript compiler API is unavailable.
Copy file name to clipboardExpand all lines: docs/01-app/03-api-reference/05-config/02-typescript.mdx
+3-28Lines changed: 3 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ To add TypeScript to an existing project, rename a file to `.ts` / `.tsx`. Run `
13
13
14
14
## Using TypeScript 7
15
15
16
-
[TypeScript 7](https://devblogs.microsoft.com/typescript/announcing-typescript-7-0/) does not currently provide the JavaScript compiler API that Next.js uses for type checking by default. To use TypeScript 7 during `next build`, install it in your project:
16
+
[TypeScript 7](https://devblogs.microsoft.com/typescript/announcing-typescript-7-0/) does not currently provide the JavaScript compiler API. To use TypeScript 7 during `next build`, install it in your project:
17
17
18
18
```bash package="pnpm"
19
19
pnpm add -D typescript@^7
@@ -31,32 +31,7 @@ yarn add -D typescript@^7
31
31
bun add -D typescript@^7
32
32
```
33
33
34
-
Then, opt in to running the project-local `tsc` CLI instead of the JavaScript API with [`experimental.useTypeScriptCli`](/docs/app/api-reference/config/next-config-js/useTypeScriptCli):
35
-
36
-
```ts filename="next.config.ts" switcher
37
-
importtype { NextConfig } from'next'
38
-
39
-
const nextConfig:NextConfig= {
40
-
experimental: {
41
-
useTypeScriptCli: true,
42
-
},
43
-
}
44
-
45
-
exportdefaultnextConfig
46
-
```
47
-
48
-
```js filename="next.config.js" switcher
49
-
/**@type{import('next').NextConfig}*/
50
-
constnextConfig= {
51
-
experimental: {
52
-
useTypeScriptCli:true,
53
-
},
54
-
}
55
-
56
-
module.exports= nextConfig
57
-
```
58
-
59
-
Next.js does not enable this option automatically. If you install TypeScript 7 without enabling `experimental.useTypeScriptCli`, `next build` exits with instructions to enable the option or install a TypeScript version supported by the default checker.
34
+
Next.js uses the project-local `tsc` CLI by default, so no additional configuration is required. To use the JavaScript compiler API instead, set [`experimental.useTypeScriptCli`](/docs/app/api-reference/config/next-config-js/useTypeScriptCli) to `false`.
60
35
61
36
> **Good to know**:
62
37
>
@@ -85,7 +60,7 @@ You can enable the plugin in VS Code by:
85
60
height="637"
86
61
/>
87
62
88
-
Now, when editing files, the custom plugin will be enabled. By default, the custom type checker is used when running `next build`. When[`experimental.useTypeScriptCli`](#using-typescript-7)is enabled, the project-local `tsc` CLI is used instead.
63
+
Now, when editing files, the custom plugin will be enabled. By default, the project-local `tsc` CLI is used when running `next build`. Set[`experimental.useTypeScriptCli`](#using-typescript-7)to `false` to use the custom type checker instead.
Copy file name to clipboardExpand all lines: packages/next/errors.json
+3-1Lines changed: 3 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1463,5 +1463,7 @@
1463
1463
"1462": "Unexpected chunk emitted in Before stage",
1464
1464
"1463": "\\`experimental.turbopackGenerateComponentChunks\\` has been moved to \\`experimental.turbopackChunking.generateComponentChunks\\`. Please update your next.config.js file accordingly.",
1465
1465
"1464": "\\`experimental.turbopackChunkingHeuristics\\` has been renamed to \\`experimental.turbopackChunking\\`. Please update your next.config.js file accordingly.",
1466
-
"1465": "\\`experimental.useCache\\` cannot be disabled when \\`cacheComponents\\` is enabled, because Cache Components relies on the \\`\"use cache\"\\` directive. Please remove it from %s."
1466
+
"1465": "\\`experimental.useCache\\` cannot be disabled when \\`cacheComponents\\` is enabled, because Cache Components relies on the \\`\"use cache\"\\` directive. Please remove it from %s.",
1467
+
"1466": "TypeScript %s does not provide the compiler API required by Next.js. Set %s to true in your Next.js config to use the TypeScript CLI, or install TypeScript 6 instead.",
1468
+
"1467": "TypeScript %s does not provide the compiler API required by Next.js. Set %s back to true in your Next.js config to use the TypeScript CLI, or install TypeScript 6 instead."
0 commit comments