Skip to content

Commit

Permalink
perf: 优化全局 ts 配置
Browse files Browse the repository at this point in the history
  • Loading branch information
pany-ang committed Nov 21, 2024
1 parent ea253ab commit d29e5ba
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 9 deletions.
11 changes: 10 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// https://www.typescriptlang.org/tsconfig
// https://cn.vuejs.org/guide/typescript/overview#configuring-tsconfig-json
// https://cn.vite.dev/guide/features#typescript-compiler-options

{
"compilerOptions": {
"target": "esnext",
Expand Down Expand Up @@ -27,6 +29,13 @@
"isolatedModules": true,
"skipLibCheck": true
},
// 编译器默认排除的编译文件
// 需要被编译的文件列表
"include": [
"**/*.ts",
"**/*.tsx",
"**/*.vue",
"**/*.d.ts"
],
// 从编译中排除的文件列表
"exclude": ["node_modules", "dist"]
}
2 changes: 1 addition & 1 deletion types/env.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** 声明 vite 环境变量的类型(如果未声明则默认是 any) */
interface ImportMetaEnv {
readonly VITE_APP_TITLE: string
readonly VITE_BASE_API: string
readonly VITE_BASE_URL: string
readonly VITE_ROUTER_HISTORY: "hash" | "html5"
readonly VITE_PUBLIC_PATH: string
}
Expand Down
6 changes: 3 additions & 3 deletions types/global-components.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type SvgIcon from "@/components/SvgIcon/index.vue"

/** 由 app.component 全局注册的组件需要在这里声明 TS 类型才能获得 Volar 插件提供的类型提示) */
export {}

// 由 app.component 全局注册的组件需要在这里声明 TS 类型才能获得 Volar 插件提供的类型提示)
declare module "vue" {
export interface GlobalComponents {
SvgIcon: typeof SvgIcon
}
}

export {}
11 changes: 11 additions & 0 deletions types/global-directives.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { Directive } from "vue"

export {}

// 由 app.directive 全局注册的自定义指令需要在这里声明 TS 类型才能获得类型提示
declare module "vue" {
export interface ComponentCustomProperties {
vLoading: Directive<Element, boolean>
vPermission: Directive<Element, string[]>
}
}
4 changes: 0 additions & 4 deletions types/shims-vue.d.ts

This file was deleted.

2 changes: 2 additions & 0 deletions types/vue-router.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import "vue-router"

export {}

declare module "vue-router" {
interface RouteMeta {
/**
Expand Down

0 comments on commit d29e5ba

Please sign in to comment.