diff --git a/tsconfig.json b/tsconfig.json index dcc7d46..6f09e6c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -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"] } diff --git a/types/env.d.ts b/types/env.d.ts index 7856644..4b07d10 100644 --- a/types/env.d.ts +++ b/types/env.d.ts @@ -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 } diff --git a/types/global-components.d.ts b/types/global-components.d.ts index 9dc2296..0832cc8 100644 --- a/types/global-components.d.ts +++ b/types/global-components.d.ts @@ -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 {} diff --git a/types/global-directives.d.ts b/types/global-directives.d.ts new file mode 100644 index 0000000..0eb4e2d --- /dev/null +++ b/types/global-directives.d.ts @@ -0,0 +1,11 @@ +import type { Directive } from "vue" + +export {} + +// 由 app.directive 全局注册的自定义指令需要在这里声明 TS 类型才能获得类型提示 +declare module "vue" { + export interface ComponentCustomProperties { + vLoading: Directive + vPermission: Directive + } +} diff --git a/types/shims-vue.d.ts b/types/shims-vue.d.ts deleted file mode 100644 index 4d4e42f..0000000 --- a/types/shims-vue.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -declare module "*.scss" { - const scss: Record - export default scss -} diff --git a/types/vue-router.d.ts b/types/vue-router.d.ts index bab831f..83cc1bd 100644 --- a/types/vue-router.d.ts +++ b/types/vue-router.d.ts @@ -1,5 +1,7 @@ import "vue-router" +export {} + declare module "vue-router" { interface RouteMeta { /**