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
Copy file name to clipboardExpand all lines: docs/guide/api-hmr.md
+7-3Lines changed: 7 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,10 +62,14 @@ if (import.meta.hot) {
62
62
63
63
## IntelliSense for TypeScript
64
64
65
-
Vite provides type definitions for `import.meta.hot` in [`vite/client.d.ts`](https://github.com/vitejs/vite/blob/main/packages/vite/client.d.ts). You can create an `vite-env.d.ts` in the `src` directory so TypeScript picks up the type definitions:
65
+
Vite provides type definitions for `import.meta.hot` in [`vite/client.d.ts`](https://github.com/vitejs/vite/blob/main/packages/vite/client.d.ts). You can add "vite/client" in the `tsconfig.json` so TypeScript picks up the type definitions:
Copy file name to clipboardExpand all lines: docs/guide/features.md
+17-11Lines changed: 17 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -113,15 +113,7 @@ Vite starter templates have `"skipLibCheck": "true"` by default to avoid typeche
113
113
114
114
### Client Types
115
115
116
-
Vite's default types are for its Node.js API. To shim the environment of client-side code in a Vite application, add a `d.ts` declaration file:
117
-
118
-
```typescript
119
-
/// <referencetypes="vite/client" />
120
-
```
121
-
122
-
::: details Using `compilerOptions.types`
123
-
124
-
Alternatively, you can add `vite/client` to `compilerOptions.types` inside `tsconfig.json`:
116
+
Vite's default types are for its Node.js API. To shim the environment of client-side code in a Vite application, you can add `vite/client` to `compilerOptions.types` inside `tsconfig.json`:
125
117
126
118
```json [tsconfig.json]
127
119
{
@@ -131,7 +123,15 @@ Alternatively, you can add `vite/client` to `compilerOptions.types` inside `tsco
131
123
}
132
124
```
133
125
134
-
Note that if [`compilerOptions.types`](https://www.typescriptlang.org/tsconfig#types) is specified, only these packages will be included in the global scope (instead of all visible ”@types” packages).
126
+
Note that if [`compilerOptions.types`](https://www.typescriptlang.org/tsconfig#types) is specified, only these packages will be included in the global scope (instead of all visible ”@types” packages). This is recommended since TS 5.9.
127
+
128
+
::: details Using triple-slash directive
129
+
130
+
Alternatively, you can add a `d.ts` declaration file:
131
+
132
+
```typescript [vite-env.d.ts]
133
+
/// <referencetypes="vite/client" />
134
+
```
135
135
136
136
:::
137
137
@@ -153,7 +153,13 @@ For example, to make the default import of `*.svg` a React component:
153
153
exportdefaultcontent
154
154
}
155
155
```
156
-
- The file containing the reference to `vite/client` (normally `vite-env.d.ts`):
156
+
- If you are using `compilerOptions.types`, ensure the file is included in `tsconfig.json`:
157
+
```json [tsconfig.json]
158
+
{
159
+
"include": ["src", "./vite-env-override.d.ts"]
160
+
}
161
+
```
162
+
- If you are using triple-slash directives, update the file containing the reference to `vite/client` (normally `vite-env.d.ts`):
0 commit comments