diff --git a/components/select/index.tsx b/components/select/index.tsx index e43462c6e..ac3662ed6 100644 --- a/components/select/index.tsx +++ b/components/select/index.tsx @@ -39,7 +39,17 @@ export interface SelectPropsTypes } export type SelectTypes = SelectPropsTypes; export const SelectProps = () => ({ - ...omit(BaseProps(), ['inputIcon', 'mode', 'getInputElement', 'backfill', 'class', 'style']), + ...(omit(BaseProps(), [ + 'inputIcon', + 'mode', + 'getInputElement', + 'backfill', + 'class', + 'style', + ]) as Omit< + ReturnType, + 'inputIcon' | 'mode' | 'getInputElement' | 'backfill' | 'class' | 'style' + >), value: { type: [Array, Object, String, Number] as PropType, }, diff --git a/components/tree-select/index.jsx b/components/tree-select/index.tsx similarity index 93% rename from components/tree-select/index.jsx rename to components/tree-select/index.tsx index d14c03010..d23b184d0 100644 --- a/components/tree-select/index.jsx +++ b/components/tree-select/index.tsx @@ -1,9 +1,10 @@ import VcTreeSelect, { TreeNode, SHOW_ALL, SHOW_PARENT, SHOW_CHILD } from '../vc-tree-select'; -import { inject } from 'vue'; +import { App, defineComponent, inject } from 'vue'; import classNames from '../_util/classNames'; import { TreeSelectProps } from './interface'; import warning from '../_util/warning'; -import { initDefaultProps, getOptionProps, getComponent, getSlot } from '../_util/props-util'; +import { getOptionProps, getComponent, getSlot } from '../_util/props-util'; +import initDefaultProps from '../_util/props-util/initDefaultProps'; import { defaultConfigProvider } from '../config-provider'; export { TreeData, TreeSelectProps } from './interface'; @@ -14,7 +15,7 @@ import CloseOutlined from '@ant-design/icons-vue/CloseOutlined'; import CloseCircleOutlined from '@ant-design/icons-vue/CloseCircleOutlined'; import omit from 'omit.js'; -const TreeSelect = { +const TreeSelect = defineComponent({ TreeNode, SHOW_ALL, SHOW_PARENT, @@ -28,6 +29,7 @@ const TreeSelect = { }), setup() { return { + vcTreeSelect: null, configProvider: inject('configProvider', defaultConfigProvider), }; }, @@ -111,7 +113,7 @@ const TreeSelect = { }, render() { - const props = getOptionProps(this); + const props: any = getOptionProps(this); const { prefixCls: customizePrefixCls, size, @@ -121,10 +123,9 @@ const TreeSelect = { ...restProps } = props; const { class: className } = this.$attrs; - const getPrefixCls = this.configProvider.getPrefixCls; + const { renderEmpty, getPrefixCls } = this.configProvider; const prefixCls = getPrefixCls('select', customizePrefixCls); - const renderEmpty = this.configProvider.renderEmpty; const notFoundContent = getComponent(this, 'notFoundContent'); const removeIcon = getComponent(this, 'removeIcon'); const clearIcon = getComponent(this, 'clearIcon'); @@ -145,7 +146,7 @@ const TreeSelect = { const cls = { [`${prefixCls}-lg`]: size === 'large', [`${prefixCls}-sm`]: size === 'small', - [className]: className, + [className as string]: className, }; // showSearch: single - false, multiple - true @@ -196,10 +197,10 @@ const TreeSelect = { /> ); }, -}; +}); /* istanbul ignore next */ -TreeSelect.install = function(app) { +TreeSelect.install = function(app: App) { app.component(TreeSelect.name, TreeSelect); app.component('ATreeSelectNode', TreeSelect.TreeNode); return app; diff --git a/components/tree-select/interface.jsx b/components/tree-select/interface.jsx index fbf2aa1eb..bcde54e8e 100644 --- a/components/tree-select/interface.jsx +++ b/components/tree-select/interface.jsx @@ -1,5 +1,6 @@ import PropTypes, { withUndefined } from '../_util/vue-types'; import { SelectProps } from '../select'; +import { tuple } from '../_util/type'; export const TreeData = PropTypes.shape({ key: PropTypes.string, @@ -35,7 +36,7 @@ export const TreeSelectProps = () => ({ notFoundContent: PropTypes.any, searchPlaceholder: PropTypes.string, searchValue: PropTypes.string, - showCheckedStrategy: PropTypes.oneOf(['SHOW_ALL', 'SHOW_PARENT', 'SHOW_CHILD']), + showCheckedStrategy: PropTypes.oneOf(tuple('SHOW_ALL', 'SHOW_PARENT', 'SHOW_CHILD')), suffixIcon: PropTypes.any, treeCheckable: PropTypes.looseBool, treeCheckStrictly: PropTypes.looseBool, diff --git a/components/tree-select/style/index.js b/components/tree-select/style/index.ts similarity index 100% rename from components/tree-select/style/index.js rename to components/tree-select/style/index.ts