From 321989b9c2219ef2cdfdcd9b772c45765c2fb029 Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Wed, 15 Feb 2023 15:33:54 +0800 Subject: [PATCH] feat: update collapse type --- components/_util/type.ts | 4 ++-- components/collapse/commonProps.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/components/_util/type.ts b/components/_util/type.ts index 2433181ac..5bed7f248 100644 --- a/components/_util/type.ts +++ b/components/_util/type.ts @@ -74,6 +74,6 @@ export function stringType(defaultVal?: T) { return { type: String as unknown as PropType, default: defaultVal as T }; } -export function someType(types: any[], defaultVal?: T) { - return { type: types as PropType, default: defaultVal as T }; +export function someType(types?: any[], defaultVal?: T) { + return types ? { type: types as PropType, default: defaultVal as T } : anyType(defaultVal); } diff --git a/components/collapse/commonProps.ts b/components/collapse/commonProps.ts index 8069e0c81..80ef4c343 100644 --- a/components/collapse/commonProps.ts +++ b/components/collapse/commonProps.ts @@ -1,5 +1,5 @@ import type { Key } from '../_util/type'; -import { tuple, booleanType, someType, stringType, functionType } from '../_util/type'; +import { booleanType, someType, stringType, functionType } from '../_util/type'; import PropTypes from '../_util/vue-types'; export type CollapsibleType = 'header' | 'icon' | 'disabled'; @@ -26,7 +26,7 @@ const collapseProps = () => ({ bordered: booleanType(), expandIcon: functionType<(panelProps: PanelProps) => any>(), openAnimation: PropTypes.object, - expandIconPosition: PropTypes.oneOf(tuple('start', 'end')), + expandIconPosition: stringType<'start' | 'end'>(), collapsible: stringType(), ghost: booleanType(), onChange: functionType<(key: Key | Key[]) => void>(), @@ -47,7 +47,7 @@ const collapsePanelProps = () => ({ forceRender: booleanType(), expandIcon: functionType<(panelProps: PanelProps) => any>(), extra: PropTypes.any, - panelKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), + panelKey: someType(), collapsible: stringType(), role: String, onItemClick: functionType<(panelKey: Key) => void>(),