From 49d4b3166e759f41adfbe17a07d446a86f7d7840 Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Fri, 13 Sep 2024 19:33:38 +0800 Subject: [PATCH] feat: update type --- components/image/index.tsx | 4 ++-- components/message/useMessage.tsx | 4 +++- components/vc-image/src/Image.tsx | 2 ++ components/vc-notification/Notification.tsx | 7 ++++--- components/vc-overflow/Overflow.tsx | 6 ++++-- .../vc-picker/panels/TimePanel/TimeUnitColumn.tsx | 4 ++-- components/vc-table/Cell/index.tsx | 6 +++--- components/vc-table/Footer/Cell.tsx | 4 ++-- components/vc-table/Table.tsx | 10 +++++----- components/vc-table/hooks/useColumns.tsx | 2 +- components/vc-trigger/Popup/PopupInner.tsx | 4 ++-- 11 files changed, 30 insertions(+), 23 deletions(-) diff --git a/components/image/index.tsx b/components/image/index.tsx index 0e752b486..7275f2bee 100644 --- a/components/image/index.tsx +++ b/components/image/index.tsx @@ -13,10 +13,10 @@ export type ImageProps = Partial< ExtractPropTypes> & Omit >; -const Image = defineComponent({ +const Image = defineComponent({ name: 'AImage', inheritAttrs: false, - props: imageProps() as any, + props: imageProps(), setup(props, { slots, attrs }) { const { prefixCls, rootPrefixCls, configProvider } = useConfigInject('image', props); // Style diff --git a/components/message/useMessage.tsx b/components/message/useMessage.tsx index e4e929eb2..f1ae5325f 100644 --- a/components/message/useMessage.tsx +++ b/components/message/useMessage.tsx @@ -47,7 +47,9 @@ const Holder = defineComponent({ 'rtl', 'transitionName', 'onAllRemoved', - ] as any, + 'animation', + 'staticGetContainer', + ], setup(props, { expose }) { const { getPrefixCls, getPopupContainer } = useConfigInject('message', props); diff --git a/components/vc-image/src/Image.tsx b/components/vc-image/src/Image.tsx index 5c68b8769..c16839485 100644 --- a/components/vc-image/src/Image.tsx +++ b/components/vc-image/src/Image.tsx @@ -32,6 +32,8 @@ export const imageProps = () => ({ rootClassName: String, prefixCls: String, previewPrefixCls: String, + width: [Number, String], + height: [Number, String], previewMask: { type: [Boolean, Function] as PropType any)>, default: undefined, diff --git a/components/vc-notification/Notification.tsx b/components/vc-notification/Notification.tsx index ff4bd02ff..39ac71c54 100644 --- a/components/vc-notification/Notification.tsx +++ b/components/vc-notification/Notification.tsx @@ -2,6 +2,7 @@ import { getTransitionGroupProps } from '../_util/transition'; import type { Key, VueNode } from '../_util/type'; import type { CSSProperties } from 'vue'; import { + toRaw, shallowRef, createVNode, computed, @@ -72,10 +73,10 @@ type NotificationState = { holderCallback?: HolderReadyCallback; }[]; -const Notification = defineComponent({ +const Notification = defineComponent({ name: 'Notification', inheritAttrs: false, - props: ['prefixCls', 'transitionName', 'animation', 'maxCount', 'closeIcon', 'hashId'] as any, + props: ['prefixCls', 'transitionName', 'animation', 'maxCount', 'closeIcon', 'hashId'], setup(props, { attrs, expose, slots }) { const hookRefs = new Map(); const notices = ref([]); @@ -125,7 +126,7 @@ const Notification = defineComponent({ }; const remove = (removeKey: Key) => { - notices.value = notices.value.filter(({ notice: { key, userPassKey } }) => { + notices.value = toRaw(notices.value as any).filter(({ notice: { key, userPassKey } }) => { const mergedKey = userPassKey || key; return mergedKey !== removeKey; }); diff --git a/components/vc-overflow/Overflow.tsx b/components/vc-overflow/Overflow.tsx index ac5445608..1196d17e5 100644 --- a/components/vc-overflow/Overflow.tsx +++ b/components/vc-overflow/Overflow.tsx @@ -39,14 +39,15 @@ const overflowProps = () => { /** When set to `full`, ssr will render full items by default and remove at client side */ ssr: String as PropType<'full'>, onMousedown: Function as PropType, + role: String, }; }; type InterOverflowProps = Partial>>; export type OverflowProps = HTMLAttributes & InterOverflowProps; -const Overflow = defineComponent({ +const Overflow = defineComponent({ name: 'Overflow', inheritAttrs: false, - props: overflowProps() as any, + props: overflowProps(), emits: ['visibleChange'], setup(props, { attrs, emit, slots }) { const fullySSR = computed(() => props.ssr === 'full'); @@ -331,6 +332,7 @@ const Overflow = defineComponent({ class={classNames(!invalidate.value && prefixCls, className)} style={style} onMousedown={onMousedown} + role={props.role} {...restAttrs} > {mergedData.value.map(internalRenderItemNode)} diff --git a/components/vc-picker/panels/TimePanel/TimeUnitColumn.tsx b/components/vc-picker/panels/TimePanel/TimeUnitColumn.tsx index 15e3544a9..9b1fc065a 100644 --- a/components/vc-picker/panels/TimePanel/TimeUnitColumn.tsx +++ b/components/vc-picker/panels/TimePanel/TimeUnitColumn.tsx @@ -18,9 +18,9 @@ export type TimeUnitColumnProps = { onSelect?: (value: number) => void; }; -export default defineComponent({ +export default defineComponent({ name: 'TimeUnitColumn', - props: ['prefixCls', 'units', 'onSelect', 'value', 'active', 'hideDisabledOptions'] as any, + props: ['prefixCls', 'units', 'onSelect', 'value', 'active', 'hideDisabledOptions'], setup(props) { const { open } = useInjectPanel(); diff --git a/components/vc-table/Cell/index.tsx b/components/vc-table/Cell/index.tsx index 9bd49d898..0b9a9edcf 100644 --- a/components/vc-table/Cell/index.tsx +++ b/components/vc-table/Cell/index.tsx @@ -77,7 +77,7 @@ export interface CellProps { transformCellText?: TransformCellText; } -export default defineComponent({ +export default defineComponent({ name: 'Cell', props: [ 'prefixCls', @@ -104,7 +104,7 @@ export default defineComponent({ 'column', 'cellType', 'transformCellText', - ] as any, + ], setup(props, { slots }) { const contextSlots = useInjectSlots(); const { onHover, startRow, endRow } = useInjectHover(); @@ -318,7 +318,7 @@ export default defineComponent({ // ====================== Render ====================== let title: string; - const ellipsisConfig: CellEllipsisType = ellipsis === true ? { showTitle: true } : ellipsis; + const ellipsisConfig = ellipsis === true ? { showTitle: true } : ellipsis; if (ellipsisConfig && (ellipsisConfig.showTitle || rowType === 'header')) { if (typeof childNode === 'string' || typeof childNode === 'number') { title = childNode.toString(); diff --git a/components/vc-table/Footer/Cell.tsx b/components/vc-table/Footer/Cell.tsx index 74b9d5a36..5f1d4d825 100644 --- a/components/vc-table/Footer/Cell.tsx +++ b/components/vc-table/Footer/Cell.tsx @@ -12,9 +12,9 @@ export interface SummaryCellProps { align?: AlignType; } -export default defineComponent({ +export default defineComponent({ name: 'ATableSummaryCell', - props: ['index', 'colSpan', 'rowSpan', 'align'] as any, + props: ['index', 'colSpan', 'rowSpan', 'align'], setup(props, { attrs, slots }) { const tableContext = useInjectTable(); const summaryContext = useInjectSummary(); diff --git a/components/vc-table/Table.tsx b/components/vc-table/Table.tsx index fa14aaa8d..d68688787 100644 --- a/components/vc-table/Table.tsx +++ b/components/vc-table/Table.tsx @@ -149,7 +149,7 @@ export interface TableProps { transformCellText?: TransformCellText; } -export default defineComponent>({ +export default defineComponent({ name: 'VcTable', inheritAttrs: false, props: [ @@ -191,7 +191,7 @@ export default defineComponent>({ 'canExpandable', 'onUpdateInternalRefs', 'transformCellText', - ] as any, + ], emits: ['expand', 'expandedRowsChange', 'updateInternalRefs', 'update:expandedRowKeys'], setup(props, { attrs, slots, emit }) { const mergedData = computed(() => props.data || EMPTY_DATA); @@ -271,7 +271,7 @@ export default defineComponent>({ // defalutXxxx 仅仅第一次生效 stop(); - const mergedExpandedKeys = computed( + const mergedExpandedKeys = computed>( () => new Set(props.expandedRowKeys || innerExpandedKeys.value || []), ); @@ -282,9 +282,9 @@ export default defineComponent>({ const hasKey = mergedExpandedKeys.value.has(key); if (hasKey) { mergedExpandedKeys.value.delete(key); - newExpandedKeys = [...mergedExpandedKeys.value]; + newExpandedKeys = [...(mergedExpandedKeys.value as any)]; } else { - newExpandedKeys = [...mergedExpandedKeys.value, key]; + newExpandedKeys = [...(mergedExpandedKeys.value as any), key]; } innerExpandedKeys.value = newExpandedKeys; diff --git a/components/vc-table/hooks/useColumns.tsx b/components/vc-table/hooks/useColumns.tsx index 811c1e24e..adc2f5bd4 100644 --- a/components/vc-table/hooks/useColumns.tsx +++ b/components/vc-table/hooks/useColumns.tsx @@ -108,7 +108,7 @@ function useColumns( prefixCls?: Ref; columns?: Ref>; expandable: Ref; - expandedKeys: Ref>; + expandedKeys: ComputedRef>; getRowKey: Ref>; onTriggerExpand: TriggerEventHandler; expandIcon?: Ref>; diff --git a/components/vc-trigger/Popup/PopupInner.tsx b/components/vc-trigger/Popup/PopupInner.tsx index df9b4c26a..441df4cd5 100644 --- a/components/vc-trigger/Popup/PopupInner.tsx +++ b/components/vc-trigger/Popup/PopupInner.tsx @@ -204,11 +204,11 @@ export default defineComponent({ class={mergedClassName} onMouseenter={onMouseenter} onMouseleave={onMouseleave} - onMousedown={withModifiers(onMousedown, ['capture'])} + onMousedown={withModifiers(onMousedown, ['capture'] as any)} {...{ [supportsPassive ? 'onTouchstartPassive' : 'onTouchstart']: withModifiers( onTouchstart, - ['capture'], + ['capture'] as any, ), }} style={mergedStyle}