perf: 优化全局 ts 配置

This commit is contained in:
pany 2024-11-21 19:52:07 +08:00
parent ea253ab1a9
commit d29e5ba062
6 changed files with 27 additions and 9 deletions

View File

@ -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",
@ -27,6 +29,13 @@
"isolatedModules": true,
"skipLibCheck": true
},
//
//
"include": [
"**/*.ts",
"**/*.tsx",
"**/*.vue",
"**/*.d.ts"
],
//
"exclude": ["node_modules", "dist"]
}

2
types/env.d.ts vendored
View File

@ -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
}

View File

@ -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
types/global-directives.d.ts vendored Normal file
View File

@ -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[]>
}
}

View File

@ -1,4 +0,0 @@
declare module "*.scss" {
const scss: Record<string, string>
export default scss
}

View File

@ -1,5 +1,7 @@
import "vue-router"
export {}
declare module "vue-router" {
interface RouteMeta {
/**