From b1bdb6de8b201c0c2d06e2b8bf9cd253ae2343c9 Mon Sep 17 00:00:00 2001 From: zazzaz Date: Thu, 26 Nov 2020 23:09:31 +0800 Subject: [PATCH] build: add type (#685) * build: add type * chore: update * chore: update * chore: update * chore: update * chore: update * chore: update * chore: update --- .gitignore | 2 +- build/bincomp.js | 2 +- build/build.component.js | 3 +- build/common.js | 3 ++ build/gen-type.js | 41 +++++++++++++++++++ build/gen-version.js | 2 +- build/rollup.config.bundle.js | 4 -- package.json | 7 ++-- .../src/{checkbox.d.ts => checkbox.type.ts} | 0 packages/checkbox/src/useCheckbox.ts | 2 +- packages/element-plus/index.ts | 5 ++- .../loading/src/createLoadingComponent.ts | 2 +- packages/loading/src/index.ts | 2 +- .../src/{loading.d.ts => loading.type.ts} | 0 .../{message-box.d.ts => message-box.type.ts} | 0 packages/message-box/src/messageBox.ts | 2 +- .../notification/__tests__/notify.spec.ts | 2 +- ...notification.d.ts => notification.type.ts} | 0 packages/notification/src/notify.ts | 2 +- .../src/{Slider.d.ts => slider.type.ts} | 0 packages/slider/src/useMarks.ts | 2 +- packages/slider/src/useSlide.ts | 2 +- packages/slider/src/useSliderButton.ts | 2 +- packages/slider/src/useStops.ts | 2 +- packages/table/src/config.ts | 2 +- packages/table/src/h-helper.ts | 2 +- packages/table/src/layout-observer.ts | 2 +- packages/table/src/store/current.ts | 2 +- packages/table/src/store/expand.ts | 2 +- packages/table/src/store/helper.ts | 2 +- packages/table/src/store/index.ts | 2 +- packages/table/src/store/tree.ts | 2 +- packages/table/src/store/watcher.ts | 2 +- .../table/src/table-body/events-helper.ts | 2 +- packages/table/src/table-body/index.ts | 2 +- .../table/src/table-body/render-helper.ts | 2 +- .../table/src/table-body/styles-helper.ts | 2 +- packages/table/src/table-body/table-body.d.ts | 2 +- packages/table/src/table-column/index.ts | 2 +- .../table/src/table-column/render-helper.ts | 2 +- .../table/src/table-column/watcher-helper.ts | 2 +- packages/table/src/table-footer/index.ts | 2 +- .../table/src/table-footer/mapState-helper.ts | 2 +- .../table/src/table-footer/style-helper.ts | 2 +- .../table/src/table-header/event-helper.ts | 2 +- packages/table/src/table-header/index.ts | 2 +- .../table/src/table-header/style.helper.ts | 2 +- .../table/src/table-header/table-header.d.ts | 2 +- .../table/src/table-header/utils-helper.ts | 2 +- packages/table/src/table-layout.ts | 2 +- .../table/src/{table.d.ts => table.type.ts} | 0 packages/table/src/table/style-helper.ts | 2 +- packages/table/src/table/utils-helper.ts | 2 +- packages/table/src/util.ts | 2 +- packages/tree/src/model/node.ts | 2 +- packages/tree/src/model/tree-store.ts | 2 +- packages/tree/src/model/util.ts | 2 +- packages/tree/src/{tree.d.ts => tree.type.ts} | 0 packages/upload/src/ajax.ts | 2 +- .../src/{upload.d.ts => upload.type.ts} | 0 packages/upload/src/useHandlers.ts | 2 +- 61 files changed, 99 insertions(+), 58 deletions(-) create mode 100644 build/common.js create mode 100644 build/gen-type.js rename packages/checkbox/src/{checkbox.d.ts => checkbox.type.ts} (100%) rename packages/loading/src/{loading.d.ts => loading.type.ts} (100%) rename packages/message-box/src/{message-box.d.ts => message-box.type.ts} (100%) rename packages/notification/src/{notification.d.ts => notification.type.ts} (100%) rename packages/slider/src/{Slider.d.ts => slider.type.ts} (100%) rename packages/table/src/{table.d.ts => table.type.ts} (100%) rename packages/tree/src/{tree.d.ts => tree.type.ts} (100%) rename packages/upload/src/{upload.d.ts => upload.type.ts} (100%) diff --git a/.gitignore b/.gitignore index 547975efe9..97c81567ca 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,4 @@ coverage/ website-dist lib website/play/index.vue -ep-version.js +packages/element-plus/version.ts diff --git a/build/bincomp.js b/build/bincomp.js index 939ca26280..ad22a057e4 100644 --- a/build/bincomp.js +++ b/build/bincomp.js @@ -1,4 +1,4 @@ -/* eslint-disable */ +/* eslint-disable @typescript-eslint/no-var-requires */ const cp = require('child_process') const { getPackagesSync } = require('@lerna/project') const ora = require('ora') diff --git a/build/build.component.js b/build/build.component.js index 86d23a17e6..4590b6f9b9 100644 --- a/build/build.component.js +++ b/build/build.component.js @@ -7,11 +7,10 @@ const { nodeResolve } = require('@rollup/plugin-node-resolve') const vue = require('rollup-plugin-vue') const rollup = require('rollup') const typescript = require('rollup-plugin-typescript2') +const { noElPrefixFile } = require('./common') const deps = Object.keys(pkg.dependencies) -const noElPrefixFile = /(utils|directives|hooks|locale)/ - const runBuild = async () => { let index = 0 const pkgs = await getPackages() diff --git a/build/common.js b/build/common.js new file mode 100644 index 0000000000..331107c4d2 --- /dev/null +++ b/build/common.js @@ -0,0 +1,3 @@ +module.exports = { + noElPrefixFile: /(utils|directives|hooks|locale)/, +} diff --git a/build/gen-type.js b/build/gen-type.js new file mode 100644 index 0000000000..053a1d4820 --- /dev/null +++ b/build/gen-type.js @@ -0,0 +1,41 @@ +/* eslint-disable @typescript-eslint/no-var-requires */ +const fs = require('fs') +const path = require('path') +const { noElPrefixFile } = require('./common') + +const outsideImport = /import .* from '..\/(.*?)\/src\/.*/ + +// index.d.ts +const newIndexPath = path.resolve(__dirname, '../lib/index.d.ts') +fs.copyFileSync(path.resolve(__dirname, '../lib/element-plus/index.d.ts'), newIndexPath) +const index = fs.readFileSync(newIndexPath) +const newIndex = index.toString().replace(/@element-plus\//g, './el-').replace('el-utils', 'utils') +fs.writeFileSync(newIndexPath, newIndex) + +// remove ep +fs.rmdirSync(path.resolve(__dirname, '../lib/element-plus'), { recursive: true }) + +// remove test-utils +fs.rmdirSync(path.resolve(__dirname, '../lib/test-utils'), { recursive: true }) + +// component +const libDirPath = path.resolve(__dirname, '../lib') +fs.readdirSync(libDirPath).forEach(comp => { + if (!noElPrefixFile.test(comp)) { + if (fs.lstatSync(path.resolve(libDirPath, comp)).isDirectory()) { + // rename + const newCompName = `el-${comp}` + fs.renameSync(path.resolve(libDirPath, comp), + path.resolve(libDirPath, newCompName)) + // re-import + const imp = fs.readFileSync(path.resolve(__dirname, '../lib', newCompName, 'index.d.ts')).toString() + if(outsideImport.test(imp)) { + const newImp = imp.replace(outsideImport, (i, c) => { + return i.replace(c, `el-${c}`) + }) + fs.writeFileSync(path.resolve(__dirname, '../lib', newCompName, 'index.d.ts'), newImp) + } + } + } +}) + diff --git a/build/gen-version.js b/build/gen-version.js index 8b7d5d47b2..e1895e4ece 100644 --- a/build/gen-version.js +++ b/build/gen-version.js @@ -2,5 +2,5 @@ const fs = require('fs') const path = require('path') const { version } = require('../package.json') -fs.writeFileSync(path.resolve(__dirname, '../ep-version.js'), `export const version = '${version}' +fs.writeFileSync(path.resolve(__dirname, '../packages/element-plus/version.ts'), `export const version = '${version}' `) diff --git a/build/rollup.config.bundle.js b/build/rollup.config.bundle.js index 98c7a9333f..2708c1b653 100644 --- a/build/rollup.config.bundle.js +++ b/build/rollup.config.bundle.js @@ -1,7 +1,6 @@ // import vue from 'rollup-plugin-vue' import { nodeResolve } from '@rollup/plugin-node-resolve' import path from 'path' -import css from 'rollup-plugin-css-only' // import commonjs from '@rollup/plugin-commonjs' import { terser } from 'rollup-plugin-terser' import typescript from 'rollup-plugin-typescript2' @@ -28,9 +27,6 @@ export default [ }), typescript({ tsconfigOverride: { - compilerOptions: { - declaration: false, - }, 'include': [ 'packages/**/*', 'typings/vue-shim.d.ts', diff --git a/package.json b/package.json index f85639db2d..93951dc598 100644 --- a/package.json +++ b/package.json @@ -8,11 +8,12 @@ "gen": "bash ./scripts/gc.sh", "bootstrap": "yarn --frozen-lockfile && npx lerna bootstrap && yarn gen:version", "gen:version": "node build/gen-version.js", - "build": "yarn bootstrap && yarn clean:lib && yarn build:lib && yarn build:lib-full && yarn build:theme && yarn build:esm-bundle && yarn build:esm && yarn build:utils && yarn build:locale && yarn build:locale-umd", + "build": "yarn bootstrap && yarn clean:lib && yarn build:esm-bundle && yarn build:lib && yarn build:lib-full && yarn build:esm && yarn build:utils && yarn build:locale && yarn build:locale-umd && yarn build:theme", "clean:lib": "rimraf lib", "build:lib": "cross-env LIBMODE=core webpack --config ./build/webpack.config.js", "build:lib-full": "cross-env LIBMODE=full webpack --config ./build/webpack.config.js", - "build:esm-bundle": "rollup --config ./build/rollup.config.bundle.js", + "build:esm-bundle": "rollup --config ./build/rollup.config.bundle.js && yarn build:type", + "build:type": "node build/gen-type.js", "build:esm": "node ./build/bincomp.js", "build:utils": "cross-env BABEL_ENV=utils babel packages/utils --extensions .ts --out-dir lib/utils", "build:locale": "cross-env BABEL_ENV=utils babel packages/locale --extensions .ts --out-dir lib/locale", @@ -140,7 +141,7 @@ "packages" ], "main": "lib/index.js", - "typings": "types/index.d.ts", + "typings": "lib/index.d.ts", "unpkg": "lib/index.js", "style": "lib/theme-chalk/index.css", "browserslist": [ diff --git a/packages/checkbox/src/checkbox.d.ts b/packages/checkbox/src/checkbox.type.ts similarity index 100% rename from packages/checkbox/src/checkbox.d.ts rename to packages/checkbox/src/checkbox.type.ts diff --git a/packages/checkbox/src/useCheckbox.ts b/packages/checkbox/src/useCheckbox.ts index 96770f4aff..ceb75a8084 100644 --- a/packages/checkbox/src/useCheckbox.ts +++ b/packages/checkbox/src/useCheckbox.ts @@ -10,7 +10,7 @@ import { UPDATE_MODEL_EVENT } from '@element-plus/utils/constants' import { useGlobalConfig } from '@element-plus/utils/util' import { PartialReturnType } from '@element-plus/utils/types' import { elFormKey, elFormItemKey } from '@element-plus/form' -import { ICheckboxGroupInstance, ICheckboxProps } from './checkbox' +import { ICheckboxGroupInstance, ICheckboxProps } from './checkbox.type' import type { ElFormContext, ElFormItemContext } from '@element-plus/form' diff --git a/packages/element-plus/index.ts b/packages/element-plus/index.ts index a3af22b7eb..bd756274e3 100644 --- a/packages/element-plus/index.ts +++ b/packages/element-plus/index.ts @@ -83,11 +83,12 @@ import ElTransfer from '@element-plus/transfer' import ElTree from '@element-plus/tree' import ElUpload from '@element-plus/upload' import { use } from '@element-plus/locale' -import { version } from '../../ep-version' +import { version as version_ } from './version' import { setConfig } from '@element-plus/utils/config' - import type { InstallOptions } from '@element-plus/utils/config' +const version = version_ // version_ to fix tsc issue + const defaultInstallOpt: InstallOptions = { size: '' as ComponentSize, zIndex: 2000, diff --git a/packages/loading/src/createLoadingComponent.ts b/packages/loading/src/createLoadingComponent.ts index d1fa693fad..d713857ce5 100644 --- a/packages/loading/src/createLoadingComponent.ts +++ b/packages/loading/src/createLoadingComponent.ts @@ -1,6 +1,6 @@ import { createVNode, reactive, ref, toRefs, h, Transition, render, VNode } from 'vue' import { removeClass } from '@element-plus/utils/dom' -import type { ILoadingCreateComponentParams, ILoadingInstance } from './loading' +import type { ILoadingCreateComponentParams, ILoadingInstance } from './loading.type' export function createLoadingComponent({ options , globalLoadingOption }: ILoadingCreateComponentParams): ILoadingInstance { let vm: VNode = null diff --git a/packages/loading/src/index.ts b/packages/loading/src/index.ts index 5e91252661..886437041d 100644 --- a/packages/loading/src/index.ts +++ b/packages/loading/src/index.ts @@ -1,5 +1,5 @@ import { createLoadingComponent } from './createLoadingComponent' -import type { ILoadingOptions, ILoadingInstance, ILoadingGlobalConfig } from './loading' +import type { ILoadingOptions, ILoadingInstance, ILoadingGlobalConfig } from './loading.type' import { addClass, getStyle, removeClass } from '@element-plus/utils/dom' import PopupManager from '@element-plus/utils/popup-manager' import isServer from '@element-plus/utils/isServer' diff --git a/packages/loading/src/loading.d.ts b/packages/loading/src/loading.type.ts similarity index 100% rename from packages/loading/src/loading.d.ts rename to packages/loading/src/loading.type.ts diff --git a/packages/message-box/src/message-box.d.ts b/packages/message-box/src/message-box.type.ts similarity index 100% rename from packages/message-box/src/message-box.d.ts rename to packages/message-box/src/message-box.type.ts diff --git a/packages/message-box/src/messageBox.ts b/packages/message-box/src/messageBox.ts index 005bd86907..1960f9cc90 100644 --- a/packages/message-box/src/messageBox.ts +++ b/packages/message-box/src/messageBox.ts @@ -2,7 +2,7 @@ import { createVNode, render } from 'vue' import MessageBoxConstructor from './index.vue' import isServer from '@element-plus/utils/isServer' import { isVNode } from '../../utils/util' -import { ElMessageBoxOptions } from './message-box' +import { ElMessageBoxOptions } from './message-box.type' let currentMsg, instance diff --git a/packages/notification/__tests__/notify.spec.ts b/packages/notification/__tests__/notify.spec.ts index 4323a1e1f5..3023f8fb38 100644 --- a/packages/notification/__tests__/notify.spec.ts +++ b/packages/notification/__tests__/notify.spec.ts @@ -1,5 +1,5 @@ import Notification, { close, closeAll } from '../src/notify' -import type { INotificationHandle } from '../src/notification' +import type { INotificationHandle } from '../src/notification.type' jest.useFakeTimers() diff --git a/packages/notification/src/notification.d.ts b/packages/notification/src/notification.type.ts similarity index 100% rename from packages/notification/src/notification.d.ts rename to packages/notification/src/notification.type.ts diff --git a/packages/notification/src/notify.ts b/packages/notification/src/notify.ts index d9705dfd65..7550531314 100644 --- a/packages/notification/src/notify.ts +++ b/packages/notification/src/notify.ts @@ -1,6 +1,6 @@ import { createVNode, render } from 'vue' import NotificationConstructor from './index.vue' -import type { INotificationOptions, INotification, NotificationQueue, NotificationVM } from './notification' +import type { INotificationOptions, INotification, NotificationQueue, NotificationVM } from './notification.type' import isServer from '../../utils/isServer' import PopupManager from '../../utils/popup-manager' import { isVNode } from '../../utils/util' diff --git a/packages/slider/src/Slider.d.ts b/packages/slider/src/slider.type.ts similarity index 100% rename from packages/slider/src/Slider.d.ts rename to packages/slider/src/slider.type.ts diff --git a/packages/slider/src/useMarks.ts b/packages/slider/src/useMarks.ts index 44e222e776..e19986a780 100644 --- a/packages/slider/src/useMarks.ts +++ b/packages/slider/src/useMarks.ts @@ -1,5 +1,5 @@ import { computed } from 'vue' -import { ISliderProps, Mark } from './Slider' +import { ISliderProps, Mark } from './slider.type' export const useMarks = (props: ISliderProps) => { diff --git a/packages/slider/src/useSlide.ts b/packages/slider/src/useSlide.ts index a52c4fc758..2994b08716 100644 --- a/packages/slider/src/useSlide.ts +++ b/packages/slider/src/useSlide.ts @@ -1,7 +1,7 @@ import { computed, inject, nextTick, ref } from 'vue' import { CHANGE_EVENT } from '@element-plus/utils/constants' import { elFormKey, elFormItemKey } from '@element-plus/form' -import { ButtonRefs, ISliderInitData, ISliderProps } from './Slider' +import { ButtonRefs, ISliderInitData, ISliderProps } from './slider.type' import type { ElFormContext, ElFormItemContext } from '@element-plus/form' diff --git a/packages/slider/src/useSliderButton.ts b/packages/slider/src/useSliderButton.ts index 751194a113..3509c32508 100644 --- a/packages/slider/src/useSliderButton.ts +++ b/packages/slider/src/useSliderButton.ts @@ -1,7 +1,7 @@ import { UPDATE_MODEL_EVENT } from '@element-plus/utils/constants' import { off, on } from '@element-plus/utils/dom' import { computed, ComputedRef, inject, nextTick, ref, watch } from 'vue' -import { ISliderButtonInitData, ISliderButtonProps, ISliderProvider } from './Slider' +import { ISliderButtonInitData, ISliderButtonProps, ISliderProvider } from './slider.type' const useTooltip = (props: ISliderButtonProps, formatTooltip: ComputedRef<(value: number) => number | string>, showTooltip: ComputedRef) => { diff --git a/packages/slider/src/useStops.ts b/packages/slider/src/useStops.ts index 4db6b2e035..8c0aa52f53 100644 --- a/packages/slider/src/useStops.ts +++ b/packages/slider/src/useStops.ts @@ -1,5 +1,5 @@ import { computed, ComputedRef } from 'vue' -import { ISliderInitData, ISliderProps, Stops } from './Slider' +import { ISliderInitData, ISliderProps, Stops } from './slider.type' export const useStops = (props: ISliderProps, initData: ISliderInitData, minValue: ComputedRef, maxValue: ComputedRef): Stops => { const stops = computed(() => { diff --git a/packages/table/src/config.ts b/packages/table/src/config.ts index f9485e962c..9ef1ff5863 100644 --- a/packages/table/src/config.ts +++ b/packages/table/src/config.ts @@ -1,7 +1,7 @@ import { getPropByPath } from '@element-plus/utils/util' import ElCheckbox from '@element-plus/checkbox' import { h } from 'vue' -import { Store, TreeNode, AnyObject, TableColumnCtx } from './table' +import { Store, TreeNode, AnyObject, TableColumnCtx } from './table.type' export const cellStarts = { default: { diff --git a/packages/table/src/h-helper.ts b/packages/table/src/h-helper.ts index c824752e08..274ba53271 100644 --- a/packages/table/src/h-helper.ts +++ b/packages/table/src/h-helper.ts @@ -1,5 +1,5 @@ import { h } from 'vue' -import { TableColumnCtx } from './table' +import { TableColumnCtx } from './table.type' export function hGutter() { return h('col', { diff --git a/packages/table/src/layout-observer.ts b/packages/table/src/layout-observer.ts index b7e8a5bd7e..6001d71bf1 100644 --- a/packages/table/src/layout-observer.ts +++ b/packages/table/src/layout-observer.ts @@ -6,7 +6,7 @@ import { computed, getCurrentInstance, } from 'vue' -import { TableLayout, TableHeader, Table } from './table' +import { TableLayout, TableHeader, Table } from './table.type' function useLayoutObserver(root: Table) { const instance = getCurrentInstance() as TableHeader diff --git a/packages/table/src/store/current.ts b/packages/table/src/store/current.ts index 8bc526b2ba..b877b40197 100644 --- a/packages/table/src/store/current.ts +++ b/packages/table/src/store/current.ts @@ -1,7 +1,7 @@ import { arrayFind } from '@element-plus/utils/util' import { getRowIdentity } from '../util' import { ref, getCurrentInstance, unref } from 'vue' -import { WatcherPropsData, Table, AnyObject } from '../table' +import { WatcherPropsData, Table, AnyObject } from '../table.type' function useCurrent(watcherData: WatcherPropsData) { const instance = getCurrentInstance() as Table diff --git a/packages/table/src/store/expand.ts b/packages/table/src/store/expand.ts index 5cc9c35896..4c130bce27 100644 --- a/packages/table/src/store/expand.ts +++ b/packages/table/src/store/expand.ts @@ -1,6 +1,6 @@ import { ref, getCurrentInstance } from 'vue' import { toggleRowStatus, getKeysMap, getRowIdentity } from '../util' -import { WatcherPropsData, Table } from '../table' +import { WatcherPropsData, Table } from '../table.type' function useExpand(watcherData: WatcherPropsData) { const instance = getCurrentInstance() as Table diff --git a/packages/table/src/store/helper.ts b/packages/table/src/store/helper.ts index e3b794ded6..bef9b40a6b 100644 --- a/packages/table/src/store/helper.ts +++ b/packages/table/src/store/helper.ts @@ -1,6 +1,6 @@ import Store from './index' import { debounce } from 'lodash' -import { Table } from '../table' +import { Table } from '../table.type' export function createStore(table: Table, initialState = {}) { if (!table) { diff --git a/packages/table/src/store/index.ts b/packages/table/src/store/index.ts index b9b10eb99e..ddb1804e21 100644 --- a/packages/table/src/store/index.ts +++ b/packages/table/src/store/index.ts @@ -1,7 +1,7 @@ import { nextTick, getCurrentInstance, unref } from 'vue' import { arrayFind } from '@element-plus/utils/util' import useWatcher from './watcher' -import { Table, Store, TableColumnCtx } from '../table' +import { Table, Store, TableColumnCtx } from '../table.type' function replaceColumn(array: TableColumnCtx[], column: TableColumnCtx) { return array.map(item => { diff --git a/packages/table/src/store/tree.ts b/packages/table/src/store/tree.ts index 899c891c38..66dc0d51b4 100644 --- a/packages/table/src/store/tree.ts +++ b/packages/table/src/store/tree.ts @@ -1,6 +1,6 @@ import { walkTreeNode, getRowIdentity } from '../util' import { ref, computed, watch, getCurrentInstance, unref } from 'vue' -import { WatcherPropsData, Table, fn } from '../table' +import { WatcherPropsData, Table, fn } from '../table.type' function useTree(watcherData: WatcherPropsData) { const expandRowKeys = ref([]) diff --git a/packages/table/src/store/watcher.ts b/packages/table/src/store/watcher.ts index 014716a200..44edcd0dcc 100644 --- a/packages/table/src/store/watcher.ts +++ b/packages/table/src/store/watcher.ts @@ -11,7 +11,7 @@ import { import useExpand from './expand' import useCurrent from './current' import useTree from './tree' -import { AnyObject, Table } from '../table' +import { AnyObject, Table } from '../table.type' const sortData = (data, states) => { const sortingColumn = states.sortingColumn diff --git a/packages/table/src/table-body/events-helper.ts b/packages/table/src/table-body/events-helper.ts index 970b685a32..a0ff1b4ff1 100644 --- a/packages/table/src/table-body/events-helper.ts +++ b/packages/table/src/table-body/events-helper.ts @@ -3,7 +3,7 @@ import { getStyle, hasClass } from '@element-plus/utils/dom' import { getCell, getColumnByCell } from '../util' import { debounce } from 'lodash' import { TableBodyProps } from './table-body' -import { Table, AnyObject, TableColumnCtx } from '../table' +import { Table, AnyObject, TableColumnCtx } from '../table.type' function useEvents(props: TableBodyProps) { const instance = getCurrentInstance() diff --git a/packages/table/src/table-body/index.ts b/packages/table/src/table-body/index.ts index d1a3ec9f4d..117931a171 100644 --- a/packages/table/src/table-body/index.ts +++ b/packages/table/src/table-body/index.ts @@ -4,7 +4,7 @@ import isServer from '@element-plus/utils/isServer' import { defineComponent, getCurrentInstance, h, PropType, watch } from 'vue' import { hColgroup } from '../h-helper' import useLayoutObserver from '../layout-observer' -import { Store, Table } from '../table' +import { Store, Table } from '../table.type' import useRender from './render-helper' import { TableBodyProps } from './table-body' export default defineComponent({ diff --git a/packages/table/src/table-body/render-helper.ts b/packages/table/src/table-body/render-helper.ts index fcf3d01b0e..66fb0f8563 100644 --- a/packages/table/src/table-body/render-helper.ts +++ b/packages/table/src/table-body/render-helper.ts @@ -4,7 +4,7 @@ import useStyles from './styles-helper' import { arrayFindIndex } from '@element-plus/utils/util' import { getRowIdentity } from '../util' import { TableBodyProps } from './table-body' -import { RenderRowData, AnyObject, Table } from '../table' +import { RenderRowData, AnyObject, Table } from '../table.type' function useRender(props: TableBodyProps) { const instance = getCurrentInstance() diff --git a/packages/table/src/table-body/styles-helper.ts b/packages/table/src/table-body/styles-helper.ts index 200d15ebe5..7e310b12b1 100644 --- a/packages/table/src/table-body/styles-helper.ts +++ b/packages/table/src/table-body/styles-helper.ts @@ -1,6 +1,6 @@ import { getCurrentInstance } from 'vue' import { TableBodyProps } from './table-body' -import { Table, AnyObject, TableColumnCtx } from '../table' +import { Table, AnyObject, TableColumnCtx } from '../table.type' function useStyles(props: TableBodyProps) { const instance = getCurrentInstance() diff --git a/packages/table/src/table-body/table-body.d.ts b/packages/table/src/table-body/table-body.d.ts index 74164731e7..bcfdef2e8c 100644 --- a/packages/table/src/table-body/table-body.d.ts +++ b/packages/table/src/table-body/table-body.d.ts @@ -1,4 +1,4 @@ -import { Store, AnyObject, fn } from '../table' +import { Store, AnyObject, fn } from '../table.type' interface TableBodyProps { store: Store diff --git a/packages/table/src/table-column/index.ts b/packages/table/src/table-column/index.ts index adaf245824..b564d62fd7 100644 --- a/packages/table/src/table-column/index.ts +++ b/packages/table/src/table-column/index.ts @@ -10,7 +10,7 @@ import { import { cellStarts } from '../config' import { mergeOptions, compose } from '../util' import ElCheckbox from '@element-plus/checkbox' -import { TableColumnCtx, TableColumn } from '../table' +import { TableColumnCtx, TableColumn } from '../table.type' import useWatcher from './watcher-helper' import useRender from './render-helper' diff --git a/packages/table/src/table-column/render-helper.ts b/packages/table/src/table-column/render-helper.ts index bbd33f96c0..97adc05858 100644 --- a/packages/table/src/table-column/render-helper.ts +++ b/packages/table/src/table-column/render-helper.ts @@ -8,7 +8,7 @@ import { } from 'vue' import { cellForced, defaultRenderCell, treeCellPrefix } from '../config' import { parseWidth, parseMinWidth } from '../util' -import { TableColumn, TableColumnCtx } from '../table' +import { TableColumn, TableColumnCtx } from '../table.type' function useRender(props: TableColumnCtx, slots, owner: ComputedRef) { const instance = (getCurrentInstance() as unknown) as TableColumn diff --git a/packages/table/src/table-column/watcher-helper.ts b/packages/table/src/table-column/watcher-helper.ts index 92f5c0fcf9..b9db3879b8 100644 --- a/packages/table/src/table-column/watcher-helper.ts +++ b/packages/table/src/table-column/watcher-helper.ts @@ -1,5 +1,5 @@ import { watch, getCurrentInstance, ComputedRef } from 'vue' -import { TableColumnCtx, TableColumn } from '../table' +import { TableColumnCtx, TableColumn } from '../table.type' function useWatcher(owner: ComputedRef, props_: TableColumnCtx) { const instance = (getCurrentInstance() as unknown) as TableColumn diff --git a/packages/table/src/table-footer/index.ts b/packages/table/src/table-footer/index.ts index 6b0fafafdd..6b599b4ae1 100644 --- a/packages/table/src/table-footer/index.ts +++ b/packages/table/src/table-footer/index.ts @@ -1,5 +1,5 @@ import { defineComponent, h } from 'vue' -import { TableFooter } from '../table' +import { TableFooter } from '../table.type' import { hGutter, hColgroup } from '../h-helper' import useStyle from './style-helper' diff --git a/packages/table/src/table-footer/mapState-helper.ts b/packages/table/src/table-footer/mapState-helper.ts index e91a3659fc..8c46819fd9 100644 --- a/packages/table/src/table-footer/mapState-helper.ts +++ b/packages/table/src/table-footer/mapState-helper.ts @@ -1,5 +1,5 @@ import { computed, getCurrentInstance } from 'vue' -import { Table } from '../table' +import { Table } from '../table.type' function useMapState() { const instance = getCurrentInstance() diff --git a/packages/table/src/table-footer/style-helper.ts b/packages/table/src/table-footer/style-helper.ts index f46d83b7ab..e358f4c8d1 100644 --- a/packages/table/src/table-footer/style-helper.ts +++ b/packages/table/src/table-footer/style-helper.ts @@ -1,5 +1,5 @@ import { computed, getCurrentInstance } from 'vue' -import { Table, TableFooter, TableColumnCtx } from '../table' +import { Table, TableFooter, TableColumnCtx } from '../table.type' import useMapState from './mapState-helper' function useStyle(props: TableFooter) { diff --git a/packages/table/src/table-header/event-helper.ts b/packages/table/src/table-header/event-helper.ts index efe478dd0d..450a828955 100644 --- a/packages/table/src/table-header/event-helper.ts +++ b/packages/table/src/table-header/event-helper.ts @@ -1,7 +1,7 @@ import { getCurrentInstance, ref } from 'vue' import { hasClass, addClass, removeClass } from '@element-plus/utils/dom' import isServer from '@element-plus/utils/isServer' -import { TableColumnCtx, Table } from '../table' +import { TableColumnCtx, Table } from '../table.type' import { TableHeaderProps } from './table-header' function useEvent(props: TableHeaderProps, emit) { diff --git a/packages/table/src/table-header/index.ts b/packages/table/src/table-header/index.ts index 1af3cc0930..9adc2595b8 100644 --- a/packages/table/src/table-header/index.ts +++ b/packages/table/src/table-header/index.ts @@ -14,7 +14,7 @@ import useEvent from './event-helper' import useStyle from './style.helper' import useUtils from './utils-helper' import { hColgroup } from '../h-helper' -import { Table, TableHeader } from '../table' +import { Table, TableHeader } from '../table.type' import { TableHeaderProps } from './table-header' export default defineComponent({ diff --git a/packages/table/src/table-header/style.helper.ts b/packages/table/src/table-header/style.helper.ts index cacc32a890..7367dd70c1 100644 --- a/packages/table/src/table-header/style.helper.ts +++ b/packages/table/src/table-header/style.helper.ts @@ -1,5 +1,5 @@ import { getCurrentInstance } from 'vue' -import { TableColumnCtx, AnyObject, Table } from '../table' +import { TableColumnCtx, AnyObject, Table } from '../table.type' import { TableHeaderProps } from './table-header' function useStyle(props: TableHeaderProps) { diff --git a/packages/table/src/table-header/table-header.d.ts b/packages/table/src/table-header/table-header.d.ts index 26ce23899e..c700070ac9 100644 --- a/packages/table/src/table-header/table-header.d.ts +++ b/packages/table/src/table-header/table-header.d.ts @@ -1,4 +1,4 @@ -import { Store } from '../table' +import { Store } from '../table.type' interface TableHeaderProps { fixed: string diff --git a/packages/table/src/table-header/utils-helper.ts b/packages/table/src/table-header/utils-helper.ts index 71fa82a217..b82d9ef0f5 100644 --- a/packages/table/src/table-header/utils-helper.ts +++ b/packages/table/src/table-header/utils-helper.ts @@ -1,5 +1,5 @@ import { getCurrentInstance, computed } from 'vue' -import { Table, TableColumnCtx } from '../table' +import { Table, TableColumnCtx } from '../table.type' import { TableHeaderProps } from './table-header' const getAllColumns = (columns: TableColumnCtx[]): TableColumnCtx[] => { diff --git a/packages/table/src/table-layout.ts b/packages/table/src/table-layout.ts index 0eeccd7c29..488fc1ee9a 100644 --- a/packages/table/src/table-layout.ts +++ b/packages/table/src/table-layout.ts @@ -2,7 +2,7 @@ import { nextTick, ref, isRef, Ref } from 'vue' import scrollbarWidth from '@element-plus/utils/scrollbar-width' import isServer from '@element-plus/utils/isServer' import { parseHeight } from './util' -import { AnyObject, Table, Store, TableHeader, TableColumnCtx } from './table' +import { AnyObject, Table, Store, TableHeader, TableColumnCtx } from './table.type' class TableLayout { observers: TableHeader[] diff --git a/packages/table/src/table.d.ts b/packages/table/src/table.type.ts similarity index 100% rename from packages/table/src/table.d.ts rename to packages/table/src/table.type.ts diff --git a/packages/table/src/table/style-helper.ts b/packages/table/src/table/style-helper.ts index 0804f9b658..e8617fc43a 100644 --- a/packages/table/src/table/style-helper.ts +++ b/packages/table/src/table/style-helper.ts @@ -13,7 +13,7 @@ import { Store, TableColumnCtx, fn, -} from '../table' +} from '../table.type' function useStyle( props: TableProps, diff --git a/packages/table/src/table/utils-helper.ts b/packages/table/src/table/utils-helper.ts index 12d4cd43ee..73ffc48530 100644 --- a/packages/table/src/table/utils-helper.ts +++ b/packages/table/src/table/utils-helper.ts @@ -1,5 +1,5 @@ import { ComputedRef } from 'vue' -import { Store, AnyObject, TableLayout } from '../table' +import { Store, AnyObject, TableLayout } from '../table.type' function useUtils(store: Store, layout: TableLayout, shouldUpdateHeight: ComputedRef) { const setCurrentRow = (row: AnyObject) => { diff --git a/packages/table/src/util.ts b/packages/table/src/util.ts index 1863d75ef9..3d98e03b6c 100644 --- a/packages/table/src/util.ts +++ b/packages/table/src/util.ts @@ -1,5 +1,5 @@ import { getValueByPath } from '@element-plus/utils/util' -import { AnyObject, TableColumnCtx } from './table' +import { AnyObject, TableColumnCtx } from './table.type' export const getCell = function (event: Event): HTMLElement { let cell = event.target as HTMLElement diff --git a/packages/tree/src/model/node.ts b/packages/tree/src/model/node.ts index 03ef7dfd8d..ce7c97d69b 100644 --- a/packages/tree/src/model/node.ts +++ b/packages/tree/src/model/node.ts @@ -9,7 +9,7 @@ import { FakeNode, TreeNodeLoadedDefaultProps, TreeNodeChildState, -} from '../tree.d' +} from '../tree.type' export const getChildState = (node: Node[]): TreeNodeChildState => { let all = true diff --git a/packages/tree/src/model/tree-store.ts b/packages/tree/src/model/tree-store.ts index ec1759c402..f7342e5734 100644 --- a/packages/tree/src/model/tree-store.ts +++ b/packages/tree/src/model/tree-store.ts @@ -10,7 +10,7 @@ import { TreeStoreOptions, FilterValue, TreeNodeData, -} from '../tree.d' +} from '../tree.type' export default class TreeStore { currentNode: Node diff --git a/packages/tree/src/model/util.ts b/packages/tree/src/model/util.ts index 5557b04150..8233e3a91c 100644 --- a/packages/tree/src/model/util.ts +++ b/packages/tree/src/model/util.ts @@ -1,5 +1,5 @@ import Node from './node' -import { TreeKey, TreeNodeData } from '../tree.d' +import { TreeKey, TreeNodeData } from '../tree.type' export const NODE_KEY = '$treeNodeId' diff --git a/packages/tree/src/tree.d.ts b/packages/tree/src/tree.type.ts similarity index 100% rename from packages/tree/src/tree.d.ts rename to packages/tree/src/tree.type.ts diff --git a/packages/upload/src/ajax.ts b/packages/upload/src/ajax.ts index 6e7256a3d6..1ef7560c2f 100644 --- a/packages/upload/src/ajax.ts +++ b/packages/upload/src/ajax.ts @@ -2,7 +2,7 @@ import type { ElUploadProgressEvent, ElUploadRequestOptions, ElUploadAjaxError, -} from './upload' +} from './upload.type' function getError(action: string, option: ElUploadRequestOptions, xhr: XMLHttpRequest) { let msg: string diff --git a/packages/upload/src/upload.d.ts b/packages/upload/src/upload.type.ts similarity index 100% rename from packages/upload/src/upload.d.ts rename to packages/upload/src/upload.type.ts diff --git a/packages/upload/src/useHandlers.ts b/packages/upload/src/useHandlers.ts index ac881e025e..64f6fe5846 100644 --- a/packages/upload/src/useHandlers.ts +++ b/packages/upload/src/useHandlers.ts @@ -3,7 +3,7 @@ import { ref, watch } from 'vue' import { NOOP } from '@vue/shared' // Inline types -import type { ListType, UploadFile, ElFile, ElUploadProgressEvent, IUseHandlersProps } from './upload' +import type { ListType, UploadFile, ElFile, ElUploadProgressEvent, IUseHandlersProps } from './upload.type' type UploadRef = { abort: (file: UploadFile) => void upload: (file: ElFile) => void