Skip to content

Commit d29e5ba

Browse files
committed
perf: 优化全局 ts 配置
1 parent ea253ab commit d29e5ba

File tree

6 files changed

+27
-9
lines changed

6 files changed

+27
-9
lines changed

tsconfig.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
// https://www.typescriptlang.org/tsconfig
12
// https://cn.vuejs.org/guide/typescript/overview#configuring-tsconfig-json
23
// https://cn.vite.dev/guide/features#typescript-compiler-options
4+
35
{
46
"compilerOptions": {
57
"target": "esnext",
@@ -27,6 +29,13 @@
2729
"isolatedModules": true,
2830
"skipLibCheck": true
2931
},
30-
// 编译器默认排除的编译文件
32+
// 需要被编译的文件列表
33+
"include": [
34+
"**/*.ts",
35+
"**/*.tsx",
36+
"**/*.vue",
37+
"**/*.d.ts"
38+
],
39+
// 从编译中排除的文件列表
3140
"exclude": ["node_modules", "dist"]
3241
}

types/env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** 声明 vite 环境变量的类型(如果未声明则默认是 any) */
22
interface ImportMetaEnv {
33
readonly VITE_APP_TITLE: string
4-
readonly VITE_BASE_API: string
4+
readonly VITE_BASE_URL: string
55
readonly VITE_ROUTER_HISTORY: "hash" | "html5"
66
readonly VITE_PUBLIC_PATH: string
77
}

types/global-components.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import type SvgIcon from "@/components/SvgIcon/index.vue"
22

3-
/** 由 app.component 全局注册的组件需要在这里声明 TS 类型才能获得 Volar 插件提供的类型提示) */
3+
export {}
4+
5+
// 由 app.component 全局注册的组件需要在这里声明 TS 类型才能获得 Volar 插件提供的类型提示)
46
declare module "vue" {
57
export interface GlobalComponents {
68
SvgIcon: typeof SvgIcon
79
}
810
}
9-
10-
export {}

types/global-directives.d.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import type { Directive } from "vue"
2+
3+
export {}
4+
5+
// 由 app.directive 全局注册的自定义指令需要在这里声明 TS 类型才能获得类型提示
6+
declare module "vue" {
7+
export interface ComponentCustomProperties {
8+
vLoading: Directive<Element, boolean>
9+
vPermission: Directive<Element, string[]>
10+
}
11+
}

types/shims-vue.d.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.

types/vue-router.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import "vue-router"
22

3+
export {}
4+
35
declare module "vue-router" {
46
interface RouteMeta {
57
/**

0 commit comments

Comments
 (0)