@nuxt/docs-nightly 4.0.0-29181071.c858a078 → 4.0.0-29181314.14f0a876

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -444,7 +444,7 @@ If you prefer to use `@vue/test-utils` on its own for unit testing in Nuxt, and
444
444
 
445
445
  2. Create a `vitest.config.ts` with the following content:
446
446
 
447
- ```ts twoslash
447
+ ```ts
448
448
  import { defineConfig } from 'vitest/config'
449
449
  import vue from '@vitejs/plugin-vue'
450
450
 
@@ -980,6 +980,93 @@ const importName = genSafeVariableName
980
980
  You can automate this step by running `npx codemod@latest nuxt/4/template-compilation-changes`
981
981
  ::
982
982
 
983
+ ### TypeScript Configuration Changes
984
+
985
+ 🚦 **Impact Level**: Minimal
986
+
987
+ #### What Changed
988
+
989
+ Nuxt now generates separate TypeScript configurations for different contexts to provide better type-checking experiences:
990
+
991
+ 1. **New TypeScript configuration files**: Nuxt now generates additional TypeScript configurations:
992
+ * `.nuxt/tsconfig.app.json` - For your app code (Vue components, composables, etc.)
993
+ * `.nuxt/tsconfig.server.json` - For your server-side code (Nitro/server directory)
994
+ * `.nuxt/tsconfig.node.json` - For your build-time code (modules, `nuxt.config.ts`, etc.)
995
+ * `.nuxt/tsconfig.json` - Legacy configuration for backward compatibility
996
+
997
+ 2. **Backward compatibility**: Existing projects that extend `.nuxt/tsconfig.json` will continue to work as before.
998
+
999
+ 3. **Opt-in project references**: New projects or those wanting better type checking can adopt TypeScript's project references feature.
1000
+
1001
+ 4. **Context-specific type checking**: Each context now has appropriate compiler options and includes/excludes for its specific environment.
1002
+
1003
+ 5. **New `typescript.nodeTsConfig` option**: You can now customize the TypeScript configuration for Node.js build-time code.
1004
+
1005
+ #### Reasons for Change
1006
+
1007
+ This change provides several benefits:
1008
+
1009
+ 1. **Better type safety**: Each context (app, server, build-time) gets appropriate type checking with context-specific globals and APIs.
1010
+ 2. **Improved IDE experience**: Better IntelliSense and error reporting for different parts of your codebase.
1011
+ 3. **Cleaner separation**: Server code won't incorrectly suggest client-side APIs and vice versa.
1012
+ 4. **Performance**: TypeScript can more efficiently check code with properly scoped configurations.
1013
+
1014
+ For example, auto-imports are not available in your `nuxt.config.ts` (but previously this was not flagged by TypeScript). And while IDEs recognized the separate context hinted by `tsconfig.json` in your `server/` directory, this was not reflected in type-checking (requiring a separate step).
1015
+
1016
+ #### Migration Steps
1017
+
1018
+ **No migration is required** - existing projects will continue to work as before.
1019
+
1020
+ However, to take advantage of improved type checking, you can opt in to the new project references approach:
1021
+
1022
+ 1. **Update your root `tsconfig.json`** to use project references:
1023
+
1024
+ ```json
1025
+ {
1026
+ "files": [],
1027
+ "references": [
1028
+ { "path": "./.nuxt/tsconfig.app.json" },
1029
+ { "path": "./.nuxt/tsconfig.server.json" },
1030
+ { "path": "./.nuxt/tsconfig.node.json" }
1031
+ ]
1032
+ }
1033
+ ```
1034
+
1035
+ 2. **Remove any manual server `tsconfig.json`** files (like `server/tsconfig.json`) that extended `.nuxt/tsconfig.server.json`.
1036
+
1037
+ 3. **Update your type checking scripts** to use the build flag for project references:
1038
+
1039
+ ```diff
1040
+ - "typecheck": "nuxt prepare && vue-tsc --noEmit"
1041
+ + "typecheck": "nuxt prepare && vue-tsc -b --noEmit"
1042
+ ```
1043
+
1044
+ 4. **Configure Node.js TypeScript options** if needed:
1045
+ <!-- @case-police-ignore tsConfig -->
1046
+
1047
+ ```ts
1048
+ export default defineNuxtConfig({
1049
+ typescript: {
1050
+ // Customize app/server TypeScript config
1051
+ tsConfig: {
1052
+ compilerOptions: {
1053
+ strict: true
1054
+ }
1055
+ },
1056
+ // Customize build-time TypeScript config
1057
+ nodeTsConfig: {
1058
+ compilerOptions: {
1059
+ strict: true
1060
+ }
1061
+ }
1062
+ }
1063
+ })
1064
+ ```
1065
+
1066
+ 5. **Update any CI/build scripts** that run TypeScript checking to ensure they use the new project references approach.
1067
+
1068
+ The new configuration provides better type safety and IntelliSense for projects that opt in, while maintaining full backward compatibility for existing setups.
1069
+
983
1070
  ### Removal of Experimental Features
984
1071
 
985
1072
  🚦 **Impact Level**: Minimal
@@ -55,7 +55,7 @@ This file contains the types of any modules you are using, as well as the key ty
55
55
 
56
56
  Some of the references in the file are to files that are only generated within your `buildDir` (`.nuxt`) and therefore for full typings, you will need to run `nuxt dev` or `nuxt build`.
57
57
 
58
- ### `.nuxt/tsconfig.json`
58
+ ### `.nuxt/tsconfig.app.json`
59
59
 
60
60
  This file contains the recommended basic TypeScript configuration for your project, including resolved aliases injected by Nuxt or modules you are using, so you can get full type support and path auto-complete for aliases like `~/file` or `#build/file`.
61
61
 
@@ -74,10 +74,37 @@ Nitro also [auto-generates types](/docs/guide/concepts/server-engine#typed-api-r
74
74
  ::
75
75
 
76
76
  ::note
77
- Keep in mind that all options extended from `./.nuxt/tsconfig.json` will be overwritten by the options defined in your `tsconfig.json`.
78
- Overwriting options such as `"compilerOptions.paths"` with your own configuration will lead TypeScript to not factor in the module resolutions from `./.nuxt/tsconfig.json`. This can lead to module resolutions such as `#imports` not being recognized.
79
- :br :br
80
- In case you need to extend options provided by `./.nuxt/tsconfig.json` further, you can use the [`alias` property](/docs/api/nuxt-config#alias) within your `nuxt.config`. Nuxt will pick them up and extend `./.nuxt/tsconfig.json` accordingly.
77
+ For backward compatibility, Nuxt still generates `./.nuxt/tsconfig.json`. However, we recommend using [TypeScript project references](/docs/guide/directory-structure/tsconfig) with the new configuration files (`.nuxt/tsconfig.app.json`, `.nuxt/tsconfig.server.json`, etc.) for better type safety and performance.
78
+
79
+ If you do extend from `./.nuxt/tsconfig.json`, keep in mind that all options will be overwritten by those defined in your `tsconfig.json`. Overwriting options such as `"compilerOptions.paths"` with your own configuration will lead TypeScript to not factor in the module resolutions, which can cause module resolutions such as `#imports` to not be recognized.
80
+
81
+ In case you need to extend options further, you can use the [`alias` property](/docs/api/nuxt-config#alias) within your `nuxt.config`. Nuxt will pick them up and extend the generated TypeScript configurations accordingly.
82
+ ::
83
+
84
+ ## Project References
85
+
86
+ Nuxt uses [TypeScript project references](https://www.typescriptlang.org/docs/handbook/project-references.html) to improve type-checking performance and provide better IDE support. This feature allows TypeScript to break up your codebase into smaller, more manageable pieces.
87
+
88
+ ### How Nuxt Uses Project References
89
+
90
+ When you run `nuxt dev` or `nuxt build`, Nuxt will generate multiple `tsconfig.json` files for different parts of your application.
91
+
92
+ - **`.nuxt/tsconfig.app.json`** - Configuration for your application code
93
+ - **`.nuxt/tsconfig.node.json`** - Configuration for your `nuxt.config` and modules
94
+ - **`.nuxt/tsconfig.server.json`** - Configuration for server-side code (when applicable)
95
+ - **`.nuxt/tsconfig.json`** - Legacy configuration for backward compatibility
96
+
97
+ Each of these files is configured to reference the appropriate dependencies and provide optimal type-checking for their specific context.
98
+
99
+ ### Benefits of Project References
100
+
101
+ - **Faster builds**: TypeScript can skip rebuilding unchanged projects
102
+ - **Better IDE performance**: Your IDE can provide faster IntelliSense and error checking
103
+ - **Isolated compilation**: Errors in one part of your application don't prevent compilation of other parts
104
+ - **Clearer dependency management**: Each project explicitly declares its dependencies
105
+
106
+ ::note
107
+ The project reference setup is handled automatically by Nuxt. You typically don't need to modify these configurations manually, but understanding how they work can help you troubleshoot type-checking issues.
81
108
  ::
82
109
 
83
110
  ## Strict Checks
@@ -136,16 +136,6 @@ export const defineWrappedResponseHandler = <T extends EventHandlerRequest, D> (
136
136
  This feature is available from Nuxt >= 3.5
137
137
  ::
138
138
 
139
- To improve clarity within your IDE between the auto-imports from 'nitro' and 'vue', you can add a `~/server/tsconfig.json` with the following content:
140
-
141
- ```json [server/tsconfig.json]
142
- {
143
- "extends": "../.nuxt/tsconfig.server.json"
144
- }
145
- ```
146
-
147
- Currently, these values won't be respected when type checking ([`nuxt typecheck`](/docs/api/commands/typecheck)), but you should get better type hints in your IDE.
148
-
149
139
  ## Recipes
150
140
 
151
141
  ### Route Parameters
@@ -1,17 +1,28 @@
1
1
  ---
2
2
  title: "tsconfig.json"
3
- description: "Nuxt generates a .nuxt/tsconfig.json file with sensible defaults and your aliases."
3
+ description: "Nuxt generates multiple TypeScript configuration files with sensible defaults and your aliases."
4
4
  head.title: "tsconfig.json"
5
5
  navigation.icon: i-lucide-file
6
6
  ---
7
7
 
8
- Nuxt [automatically generates](/docs/guide/concepts/typescript) a `.nuxt/tsconfig.json` file with the resolved aliases you are using in your Nuxt project, as well as with other sensible defaults.
8
+ Nuxt [automatically generates](/docs/guide/concepts/typescript) multiple TypeScript configuration files (`.nuxt/tsconfig.app.json`, `.nuxt/tsconfig.server.json`, `.nuxt/tsconfig.node.json`) with the resolved aliases you are using in your Nuxt project, as well as with other sensible defaults.
9
9
 
10
10
  You can benefit from this by creating a `tsconfig.json` in the root of your project with the following content:
11
11
 
12
12
  ```json [tsconfig.json]
13
13
  {
14
- "extends": "./.nuxt/tsconfig.json"
14
+ "files": [],
15
+ "references": [
16
+ {
17
+ "path": "./.nuxt/tsconfig.app.json"
18
+ },
19
+ {
20
+ "path": "./.nuxt/tsconfig.server.json"
21
+ },
22
+ {
23
+ "path": "./.nuxt/tsconfig.node.json"
24
+ }
25
+ ]
15
26
  }
16
27
  ```
17
28
 
@@ -128,7 +128,7 @@ The Nuxt instance as described in the `useNuxt` section.
128
128
  ::code-group
129
129
 
130
130
  ```ts twoslash [requireSiteConfig.ts]
131
- declare module '@nuxt/schema' {
131
+ declare module 'nuxt/schema' {
132
132
  interface NuxtOptions {
133
133
  siteConfig: SiteConfig
134
134
  }
@@ -68,7 +68,7 @@ Hook | Arguments | Description
68
68
  `nitro:build:public-assets` | `nitro` | Called after copying public assets. Allows modifying public assets before Nitro server is built.
69
69
  `prerender:routes` | `ctx` | Allows extending the routes to be pre-rendered.
70
70
  `build:error` | `error` | Called when an error occurs at build time.
71
- `prepare:types` | `options` | Called before `@nuxt/cli` writes `.nuxt/tsconfig.json` and `.nuxt/nuxt.d.ts`, allowing addition of custom references and declarations in `nuxt.d.ts`, or directly modifying the options in `tsconfig.json`
71
+ `prepare:types` | `options` | Called before `@nuxt/cli` writes TypeScript configuration files (`.nuxt/tsconfig.app.json`, `.nuxt/tsconfig.server.json`, etc.) and `.nuxt/nuxt.d.ts`, allowing addition of custom references and declarations in `nuxt.d.ts`, or directly modifying the options in generated configurations
72
72
  `listen` | `listenerServer, listener` | Called when the dev server is loading.
73
73
  `schema:extend` | `schemas` | Allows extending default schemas.
74
74
  `schema:resolved` | `schema` | Allows extending resolved schema.
@@ -31,9 +31,8 @@ your alias by prefixing it with `~`.
31
31
  ::
32
32
 
33
33
  ::callout
34
- **Note**: These aliases will be automatically added to the generated `.nuxt/tsconfig.json` so you can get full
35
- type support and path auto-complete. In case you need to extend options provided by `./.nuxt/tsconfig.json`
36
- further, make sure to add them here or within the `typescript.TSConfig` property in `nuxt.config`.
34
+ <!-- @case-police-ignore tsConfig -->
35
+ **Note**: These aliases will be automatically added to the generated TypeScript configurations (`.nuxt/tsconfig.app.json`, `.nuxt/tsconfig.server.json`, etc.) so you can get full type support and path auto-complete. In case you need to extend options provided by the generated configurations further, make sure to add them here or within the `typescript.tsConfig` property in `nuxt.config`.
37
36
  ::
38
37
 
39
38
  **Example**:
@@ -2058,9 +2057,11 @@ TypeScript comes with certain checks to give you more safety and analysis of you
2058
2057
  - **Type**: `boolean`
2059
2058
  - **Default:** `true`
2060
2059
 
2061
- ### `TSConfig`
2060
+ <!-- @case-police-ignore tsConfig -->
2062
2061
 
2063
- You can extend generated `.nuxt/tsconfig.json` using this option.
2062
+ ### `tsConfig`
2063
+
2064
+ You can extend the generated TypeScript configurations (`.nuxt/tsconfig.app.json`, `.nuxt/tsconfig.server.json`, etc.) using this option.
2064
2065
 
2065
2066
  ### `typeCheck`
2066
2067
 
@@ -36,6 +36,8 @@ If you are using TypeScript, you can edit your `tsconfig.json` to benefit from a
36
36
 
37
37
  ::note
38
38
  As `.nuxt/tsconfig.json` is generated and not checked into version control, you'll need to generate that file before running your tests. Add `nuxi prepare` as a step before your tests, otherwise you'll see `TS5083: Cannot read file '~/.nuxt/tsconfig.json'`
39
+
40
+ For modern Nuxt projects, we recommend using [TypeScript project references](/docs/guide/directory-structure/tsconfig) instead of directly extending `.nuxt/tsconfig.json`.
39
41
  ::
40
42
 
41
43
  ::note
@@ -156,11 +156,22 @@ Nuxt can type-check your app using [`vue-tsc`](https://github.com/vuejs/language
156
156
 
157
157
  ```json
158
158
  {
159
- "extends": "./.nuxt/tsconfig.json"
159
+ "files": [],
160
+ "references": [
161
+ {
162
+ "path": "./.nuxt/tsconfig.app.json"
163
+ },
164
+ {
165
+ "path": "./.nuxt/tsconfig.server.json"
166
+ },
167
+ {
168
+ "path": "./.nuxt/tsconfig.node.json"
169
+ }
170
+ ]
160
171
  }
161
172
  ```
162
173
 
163
- 1. Run `npx nuxt prepare` to generate `.nuxt/tsconfig.json`.
174
+ 1. Run `npx nuxt prepare` to generate the tsconfig files.
164
175
  1. Install Volar following the instructions in the [docs](/docs/getting-started/introduction#prerequisites).
165
176
 
166
177
  ## Vue Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/docs-nightly",
3
- "version": "4.0.0-29181071.c858a078",
3
+ "version": "4.0.0-29181314.14f0a876",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/nuxt.git",