Skip to content

Commit a5a65d3

Browse files
committed
feat(vue): 合并类型定义并优化 TypeScript 配置
- 将 env.d.ts 和 vite.d.ts 合并为一个文件 - 移除多余的引用声明 - 更新 tsconfig.json,统一管理类型引用 - 调整 ImportMetaEnv 接口的位置
1 parent af64c81 commit a5a65d3

File tree

3 files changed

+17
-22
lines changed

3 files changed

+17
-22
lines changed

templates/vue/src/dts/env.d.ts

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
/**
22
* @file env.d.ts
33
* @ref https://nodejs.org/api/process.html#processenv
4-
*/
5-
6-
/// <reference types="vite/client" />
7-
/// <reference types="vitest/globals" />
8-
/// <reference types="unplugin-vue-router/client" />
4+
* @ref https://vitejs.dev/guide/env-and-mode.html#intellisense-for-typescript
5+
*/
96

107
namespace NodeJS {
118
interface ProcessEnv {
129
readonly NODE_ENV: 'development' | 'production' | 'test';
1310
}
1411
}
1512

13+
interface ImportMetaEnv {
14+
readonly VITE_API_URL: string;
15+
}
16+
17+
interface ImportMeta {
18+
readonly env: ImportMetaEnv;
19+
}

templates/vue/src/dts/vite.d.ts

-16
This file was deleted.

templates/vue/tsconfig.json

+8-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,14 @@
1919
"forceConsistentCasingInFileNames": true,
2020

2121
"lib": ["ES2023", "DOM"],
22-
"types": ["node"],
22+
"types": [
23+
"node",
24+
// vite
25+
"vite/client",
26+
"vitest/globals",
27+
// vue
28+
"unplugin-vue-router/client"
29+
],
2330
"plugins": [],
2431
"paths": {
2532
"@/*": ["./src/*"]

0 commit comments

Comments
 (0)