From 60cb2262f9c2e77a6885c5ad234f2e999a0fecb0 Mon Sep 17 00:00:00 2001 From: DDDDD12138 <43703884+DDDDD12138@users.noreply.github.com> Date: Tue, 3 Sep 2024 14:34:21 +0800 Subject: [PATCH] chore: optimize dts imports (#18051) * feat: move /typings/components.d.ts to /typings/global.d.ts * feat: use /typings/global.d.ts file * chore: adjust the order for global.d.ts --- docs/tsconfig.json | 2 +- internal/build/gulpfile.ts | 2 +- tsconfig.base.json | 3 +- tsconfig.play.json | 2 +- typings/components.d.ts | 120 ----------------------------- global.d.ts => typings/global.d.ts | 2 +- 6 files changed, 6 insertions(+), 125 deletions(-) delete mode 100644 typings/components.d.ts rename global.d.ts => typings/global.d.ts (99%) diff --git a/docs/tsconfig.json b/docs/tsconfig.json index 6f218357ff..652b6abad0 100644 --- a/docs/tsconfig.json +++ b/docs/tsconfig.json @@ -15,7 +15,7 @@ "element-plus": ["../packages/element-plus"], "~/*": ["./.vitepress/vitepress/*"] }, - "types": ["../typings/components"], + "types": ["../typings/global"], "jsx": "preserve" }, "include": ["**/*", ".vitepress/**/*"], diff --git a/internal/build/gulpfile.ts b/internal/build/gulpfile.ts index 4856839378..1b7030bf53 100644 --- a/internal/build/gulpfile.ts +++ b/internal/build/gulpfile.ts @@ -20,7 +20,7 @@ export const copyFiles = () => path.resolve(epOutput, 'README.md') ), copyFile( - path.resolve(projRoot, 'global.d.ts'), + path.resolve(projRoot, 'typings', 'global.d.ts'), path.resolve(epOutput, 'global.d.ts') ), ]) diff --git a/tsconfig.base.json b/tsconfig.base.json index 44aae94f4f..e24c5503e0 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -16,7 +16,8 @@ "rootDir": ".", "types": [], "paths": { - "@element-plus/*": ["packages/*"] + "@element-plus/*": ["packages/*"], + "element-plus": ["packages/element-plus"] }, "preserveSymlinks": true } diff --git a/tsconfig.play.json b/tsconfig.play.json index f1ecdc8618..e3ab3e26ad 100644 --- a/tsconfig.play.json +++ b/tsconfig.play.json @@ -6,7 +6,7 @@ }, "include": [ "packages", - "typings/components.d.ts", + "typings/global.d.ts", "typings/env.d.ts", // playground diff --git a/typings/components.d.ts b/typings/components.d.ts deleted file mode 100644 index 076a4d93a0..0000000000 --- a/typings/components.d.ts +++ /dev/null @@ -1,120 +0,0 @@ -declare module 'vue' { - // GlobalComponents for Volar - export interface GlobalComponents { - ElAffix: typeof import('../packages/element-plus')['ElAffix'] - ElAlert: typeof import('../packages/element-plus')['ElAlert'] - ElAside: typeof import('../packages/element-plus')['ElAside'] - ElAutocomplete: typeof import('../packages/element-plus')['ElAutocomplete'] - ElAvatar: typeof import('../packages/element-plus')['ElAvatar'] - ElBacktop: typeof import('../packages/element-plus')['ElBacktop'] - ElBadge: typeof import('../packages/element-plus')['ElBadge'] - ElBreadcrumb: typeof import('../packages/element-plus')['ElBreadcrumb'] - ElBreadcrumbItem: typeof import('../packages/element-plus')['ElBreadcrumbItem'] - ElButton: typeof import('../packages/element-plus')['ElButton'] - ElButtonGroup: typeof import('../packages/element-plus')['ElButtonGroup'] - ElCalendar: typeof import('../packages/element-plus')['ElCalendar'] - ElCard: typeof import('../packages/element-plus')['ElCard'] - ElCarousel: typeof import('../packages/element-plus')['ElCarousel'] - ElCarouselItem: typeof import('../packages/element-plus')['ElCarouselItem'] - ElCascader: typeof import('../packages/element-plus')['ElCascader'] - ElCascaderPanel: typeof import('../packages/element-plus')['ElCascaderPanel'] - ElCheckbox: typeof import('../packages/element-plus')['ElCheckbox'] - ElCheckboxButton: typeof import('../packages/element-plus')['ElCheckboxButton'] - ElCheckboxGroup: typeof import('../packages/element-plus')['ElCheckboxGroup'] - ElCol: typeof import('../packages/element-plus')['ElCol'] - ElCollapse: typeof import('../packages/element-plus')['ElCollapse'] - ElCollapseItem: typeof import('../packages/element-plus')['ElCollapseItem'] - ElCollapseTransition: typeof import('../packages/element-plus')['ElCollapseTransition'] - ElColorPicker: typeof import('../packages/element-plus')['ElColorPicker'] - ElContainer: typeof import('../packages/element-plus')['ElContainer'] - ElConfigProvider: typeof import('../packages/element-plus')['ElConfigProvider'] - ElDatePicker: typeof import('../packages/element-plus')['ElDatePicker'] - ElDialog: typeof import('../packages/element-plus')['ElDialog'] - ElDivider: typeof import('../packages/element-plus')['ElDivider'] - ElDrawer: typeof import('../packages/element-plus')['ElDrawer'] - ElDropdown: typeof import('../packages/element-plus')['ElDropdown'] - ElDropdownItem: typeof import('../packages/element-plus')['ElDropdownItem'] - ElDropdownMenu: typeof import('../packages/element-plus')['ElDropdownMenu'] - ElEmpty: typeof import('../packages/element-plus')['ElEmpty'] - ElFooter: typeof import('../packages/element-plus')['ElFooter'] - ElForm: typeof import('../packages/element-plus')['ElForm'] - ElFormItem: typeof import('../packages/element-plus')['ElFormItem'] - ElHeader: typeof import('../packages/element-plus')['ElHeader'] - ElIcon: typeof import('../packages/element-plus')['ElIcon'] - ElImage: typeof import('../packages/element-plus')['ElImage'] - ElImageViewer: typeof import('../packages/element-plus')['ElImageViewer'] - ElInput: typeof import('../packages/element-plus')['ElInput'] - ElInputNumber: typeof import('../packages/element-plus')['ElInputNumber'] - ElLink: typeof import('../packages/element-plus')['ElLink'] - ElMain: typeof import('../packages/element-plus')['ElMain'] - ElMenu: typeof import('../packages/element-plus')['ElMenu'] - ElMenuItem: typeof import('../packages/element-plus')['ElMenuItem'] - ElMenuItemGroup: typeof import('../packages/element-plus')['ElMenuItemGroup'] - ElOption: typeof import('../packages/element-plus')['ElOption'] - ElOptionGroup: typeof import('../packages/element-plus')['ElOptionGroup'] - ElPageHeader: typeof import('../packages/element-plus')['ElPageHeader'] - ElPagination: typeof import('../packages/element-plus')['ElPagination'] - ElPopconfirm: typeof import('../packages/element-plus')['ElPopconfirm'] - ElPopper: typeof import('../packages/element-plus')['ElPopper'] - ElPopover: typeof import('../packages/element-plus')['ElPopover'] - ElProgress: typeof import('../packages/element-plus')['ElProgress'] - ElRadio: typeof import('../packages/element-plus')['ElRadio'] - ElRadioButton: typeof import('../packages/element-plus')['ElRadioButton'] - ElRadioGroup: typeof import('../packages/element-plus')['ElRadioGroup'] - ElRate: typeof import('../packages/element-plus')['ElRate'] - ElRow: typeof import('../packages/element-plus')['ElRow'] - ElScrollbar: typeof import('../packages/element-plus')['ElScrollbar'] - ElSelect: typeof import('../packages/element-plus')['ElSelect'] - ElSlider: typeof import('../packages/element-plus')['ElSlider'] - ElStep: typeof import('../packages/element-plus')['ElStep'] - ElSteps: typeof import('../packages/element-plus')['ElSteps'] - ElSubMenu: typeof import('../packages/element-plus')['ElSubMenu'] - ElSwitch: typeof import('../packages/element-plus')['ElSwitch'] - ElTabPane: typeof import('../packages/element-plus')['ElTabPane'] - ElTable: typeof import('../packages/element-plus')['ElTable'] - ElTableColumn: typeof import('../packages/element-plus')['ElTableColumn'] - ElTabs: typeof import('../packages/element-plus')['ElTabs'] - ElTag: typeof import('../packages/element-plus')['ElTag'] - ElText: typeof import('../packages/element-plus')['ElText'] - ElTimePicker: typeof import('../packages/element-plus')['ElTimePicker'] - ElTimeSelect: typeof import('../packages/element-plus')['ElTimeSelect'] - ElTimeline: typeof import('../packages/element-plus')['ElTimeline'] - ElTimelineItem: typeof import('../packages/element-plus')['ElTimelineItem'] - ElTooltip: typeof import('../packages/element-plus')['ElTooltip'] - ElTransfer: typeof import('../packages/element-plus')['ElTransfer'] - ElTree: typeof import('../packages/element-plus')['ElTree'] - ElTreeV2: typeof import('../packages/element-plus')['ElTreeV2'] - ElTreeSelect: typeof import('../packages/element-plus')['ElTreeSelect'] - ElUpload: typeof import('../packages/element-plus')['ElUpload'] - ElSpace: typeof import('../packages/element-plus')['ElSpace'] - ElSkeleton: typeof import('../packages/element-plus')['ElSkeleton'] - ElSkeletonItem: typeof import('../packages/element-plus')['ElSkeletonItem'] - ElStatistic: typeof import('../packages/element-plus')['ElStatistic'] - ElCountdown: typeof import('../packages/element-plus')['ElCountdown'] - ElCheckTag: typeof import('../packages/element-plus')['ElCheckTag'] - ElDescriptions: typeof import('../packages/element-plus')['ElDescriptions'] - ElDescriptionsItem: typeof import('../packages/element-plus')['ElDescriptionsItem'] - ElResult: typeof import('../packages/element-plus')['ElResult'] - ElSelectV2: typeof import('../packages/element-plus')['ElSelectV2'] - ElWatermark: typeof import('../packages/element-plus')['ElWatermark'] - ElTour: typeof import('../packages/element-plus')['ElTour'] - ElTourStep: typeof import('../packages/element-plus')['ElTourStep'] - ElAnchor: typeof import('../packages/element-plus')['ElAnchor'] - ElAnchorLink: typeof import('../packages/element-plus')['ElAnchorLink'] - ElSegmented: typeof import('../packages/element-plus')['ElSegmented'] - ElMention: typeof import('../packages/element-plus')['ElMention'] - } - - interface ComponentCustomProperties { - $message: typeof import('../packages/element-plus')['ElMessage'] - $notify: typeof import('../packages/element-plus')['ElNotification'] - $msgbox: typeof import('../packages/element-plus')['ElMessageBox'] - $messageBox: typeof import('../packages/element-plus')['ElMessageBox'] - $alert: typeof import('../packages/element-plus')['ElMessageBox']['alert'] - $confirm: typeof import('../packages/element-plus')['ElMessageBox']['confirm'] - $prompt: typeof import('../packages/element-plus')['ElMessageBox']['prompt'] - $loading: typeof import('../packages/element-plus')['ElLoadingService'] - } -} - -export {} diff --git a/global.d.ts b/typings/global.d.ts similarity index 99% rename from global.d.ts rename to typings/global.d.ts index 1a68609b35..ac2cdad78b 100644 --- a/global.d.ts +++ b/typings/global.d.ts @@ -1,5 +1,5 @@ -// GlobalComponents for Volar declare module 'vue' { + // GlobalComponents for Volar export interface GlobalComponents { ElAffix: typeof import('element-plus')['ElAffix'] ElAlert: typeof import('element-plus')['ElAlert']