Skip to content

Commit ba8b7af

Browse files
authored
feat(create-app): improve client types (#3214)
1 parent d852731 commit ba8b7af

File tree

13 files changed

+13
-7
lines changed

13 files changed

+13
-7
lines changed

docs/guide/features.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,13 @@ Note that because `esbuild` only performs transpilation without type information
3838

3939
### Client Types
4040

41-
Vite's default types are for its Node.js API. To shim the environment of client side code in a Vite application, add `vite/client` to `compilerOptions.types` of your `tsconfig`:
41+
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:
42+
43+
```typescript
44+
/// <reference types="vite/client" />
45+
```
46+
47+
Also, you can add `vite/client` to `compilerOptions.types` of your `tsconfig`:
4248

4349
```json
4450
{
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="vite/client" />

packages/create-app/template-lit-element-ts/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"compilerOptions": {
33
"module": "esnext",
44
"lib": ["es2017", "dom", "dom.iterable"],
5-
"types": ["vite/client"],
65
"declaration": true,
76
"emitDeclarationOnly": true,
87
"outDir": "./types",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="vite/client" />

packages/create-app/template-preact-ts/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"compilerOptions": {
33
"target": "ESNext",
44
"lib": ["DOM", "DOM.Iterable", "ESNext"],
5-
"types": ["vite/client"],
65
"allowJs": false,
76
"skipLibCheck": false,
87
"esModuleInterop": false,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="vite/client" />

packages/create-app/template-react-ts/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"compilerOptions": {
33
"target": "ESNext",
44
"lib": ["DOM", "DOM.Iterable", "ESNext"],
5-
"types": ["vite/client"],
65
"allowJs": false,
76
"skipLibCheck": false,
87
"esModuleInterop": false,

packages/create-app/template-svelte-ts/src/global.d.ts renamed to packages/create-app/template-svelte-ts/src/vite-env.d.ts

File renamed without changes.
File renamed without changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="vite/client" />

0 commit comments

Comments
 (0)