Skip to content

fix: add array type to event cb props's declaration (#5410 #5414) #6138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/_util/transButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const TransButton = defineComponent({
inheritAttrs: false,
props: {
noStyle: { type: Boolean, default: undefined },
onClick: Function,
onClick: [Function, Array],
disabled: { type: Boolean, default: undefined },
autofocus: { type: Boolean, default: undefined },
},
Expand Down
4 changes: 2 additions & 2 deletions components/affix/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ export const affixProps = () => ({
},
prefixCls: String,
/** 固定状态改变时触发的回调函数 */
onChange: Function as PropType<AffixEmits['change']>,
onTestUpdatePosition: Function as PropType<AffixEmits['testUpdatePosition']>,
onChange: [Function, Array] as PropType<AffixEmits['change']>,
onTestUpdatePosition: [Function, Array] as PropType<AffixEmits['testUpdatePosition']>,
});

export type AffixProps = Partial<ExtractPropTypes<ReturnType<typeof affixProps>>>;
Expand Down
2 changes: 1 addition & 1 deletion components/alert/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const alertProps = () => ({
banner: { type: Boolean, default: undefined },
icon: PropTypes.any,
closeIcon: PropTypes.any,
onClose: Function as PropType<NodeMouseEventHandler>,
onClose: [Function, Array] as PropType<NodeMouseEventHandler>,
});

export type AlertProps = Partial<ExtractPropTypes<ReturnType<typeof alertProps>>>;
Expand Down
6 changes: 4 additions & 2 deletions components/anchor/Anchor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ export const anchorProps = () => ({
wrapperStyle: { type: Object as PropType<CSSProperties>, default: undefined as CSSProperties },
getCurrentAnchor: Function as PropType<() => string>,
targetOffset: Number,
onChange: Function as PropType<(currentActiveLink: string) => void>,
onClick: Function as PropType<(e: MouseEvent, link: { title: any; href: string }) => void>,
onChange: [Function, Array] as PropType<(currentActiveLink: string) => void>,
onClick: [Function, Array] as PropType<
(e: MouseEvent, link: { title: any; href: string }) => void
>,
});

export type AnchorProps = Partial<ExtractPropTypes<ReturnType<typeof anchorProps>>>;
Expand Down
2 changes: 1 addition & 1 deletion components/back-top/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const backTopProps = () => ({
duration: { type: Number, default: 450 },
target: Function as PropType<() => HTMLElement | Window | Document>,
prefixCls: String,
onClick: Function as PropType<MouseEventHandler>,
onClick: [Function, Array] as PropType<MouseEventHandler>,
// visible: { type: Boolean, default: undefined }, // Only for test. Don't use it.
});

Expand Down
2 changes: 1 addition & 1 deletion components/breadcrumb/BreadcrumbItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const breadcrumbItemProps = () => ({
href: String,
separator: PropTypes.any,
overlay: PropTypes.any,
onClick: Function as PropType<MouseEventHandler>,
onClick: [Function, Array] as PropType<MouseEventHandler>,
});

export type BreadcrumbItemProps = Partial<ExtractPropTypes<ReturnType<typeof breadcrumbItemProps>>>;
Expand Down
4 changes: 2 additions & 2 deletions components/button/buttonTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ export const buttonProps = () => ({
target: String,
title: String,
onClick: {
type: Function as PropType<(event: MouseEvent) => void>,
type: [Function, Array] as PropType<(event: MouseEvent) => void>,
},
onMousedown: {
type: Function as PropType<(event: MouseEvent) => void>,
type: [Function, Array] as PropType<(event: MouseEvent) => void>,
},
});

Expand Down
2 changes: 1 addition & 1 deletion components/card/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const cardProps = () => ({
defaultActiveTabKey: String,
cover: PropTypes.any,
onTabChange: {
type: Function as PropType<(key: string) => void>,
type: [Function, Array] as PropType<(key: string) => void>,
},
});

Expand Down
2 changes: 1 addition & 1 deletion components/cascader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export function cascaderProps<DataNodeType extends CascaderOptionType = Cascader
placement: { type: String as PropType<SelectCommonPlacement> },
suffixIcon: PropTypes.any,
options: Array as PropType<DataNodeType[]>,
'onUpdate:value': Function as PropType<(value: ValueType) => void>,
'onUpdate:value': [Function, Array] as PropType<(value: ValueType) => void>,
};
}

Expand Down
12 changes: 7 additions & 5 deletions components/checkbox/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ export const checkboxGroupProps = () => {
...abstractCheckboxGroupProps(),
defaultValue: { type: Array as PropType<Array<CheckboxValueType>> },
value: { type: Array as PropType<Array<CheckboxValueType>> },
onChange: { type: Function as PropType<(checkedValue: Array<CheckboxValueType>) => void> },
onChange: {
type: [Function, Array] as PropType<(checkedValue: Array<CheckboxValueType>) => void>,
},
'onUpdate:value': {
type: Function as PropType<(checkedValue: Array<CheckboxValueType>) => void>,
type: [Function, Array] as PropType<(checkedValue: Array<CheckboxValueType>) => void>,
},
};
};
Expand All @@ -63,9 +65,9 @@ export const abstractCheckboxProps = () => {
indeterminate: { type: Boolean, default: undefined },
type: { type: String, default: 'checkbox' },
autofocus: { type: Boolean, default: undefined },
onChange: Function as PropType<(e: CheckboxChangeEvent) => void>,
'onUpdate:checked': Function as PropType<(checked: boolean) => void>,
onClick: Function as PropType<MouseEventHandler>,
onChange: [Function, Array] as PropType<(e: CheckboxChangeEvent) => void>,
'onUpdate:checked': [Function, Array] as PropType<(checked: boolean) => void>,
onClick: [Function, Array] as PropType<MouseEventHandler>,
skipGroup: { type: Boolean, default: false },
};
};
Expand Down
6 changes: 3 additions & 3 deletions components/collapse/commonProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ const collapseProps = () => ({
expandIconPosition: PropTypes.oneOf(tuple('left', 'right')),
collapsible: { type: String as PropType<CollapsibleType> },
ghost: { type: Boolean, default: undefined },
onChange: Function as PropType<(key: Key | Key[]) => void>,
'onUpdate:activeKey': Function as PropType<(key: Key | Key[]) => void>,
onChange: [Function, Array] as PropType<(key: Key | Key[]) => void>,
'onUpdate:activeKey': [Function, Array] as PropType<(key: Key | Key[]) => void>,
});

const collapsePanelProps = () => ({
Expand All @@ -51,7 +51,7 @@ const collapsePanelProps = () => ({
panelKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
collapsible: { type: String as PropType<CollapsibleType> },
role: String,
onItemClick: { type: Function as PropType<(panelKey: Key) => void> },
onItemClick: { type: [Function, Array] as PropType<(panelKey: Key) => void> },
});

export { collapseProps, collapsePanelProps };
48 changes: 29 additions & 19 deletions components/date-picker/generatePicker/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,28 @@ function commonProps<DateType = any>() {
panelRender: { type: Function as PropType<(originPanel: VueNode) => VueNode> },
// // Events
onChange: {
type: Function as PropType<(value: DateType | string | null, dateString: string) => void>,
type: [Function, Array] as PropType<
(value: DateType | string | null, dateString: string) => void
>,
},
'onUpdate:value': {
type: [Function, Array] as PropType<(value: DateType | string | null) => void>,
},
'onUpdate:value': { type: Function as PropType<(value: DateType | string | null) => void> },
onOk: { type: Function as PropType<(value: DateType | string | null) => void> },
onOpenChange: { type: Function as PropType<(open: boolean) => void> },
'onUpdate:open': { type: Function as PropType<(open: boolean) => void> },
onFocus: { type: Function as PropType<FocusEventHandler> },
onBlur: { type: Function as PropType<FocusEventHandler> },
onMousedown: { type: Function as PropType<MouseEventHandler> },
onMouseup: { type: Function as PropType<MouseEventHandler> },
onMouseenter: { type: Function as PropType<MouseEventHandler> },
onMouseleave: { type: Function as PropType<MouseEventHandler> },
onClick: { type: Function as PropType<MouseEventHandler> },
onContextmenu: { type: Function as PropType<MouseEventHandler> },
onOk: { type: [Function, Array] as PropType<(value: DateType | string | null) => void> },
onOpenChange: { type: [Function, Array] as PropType<(open: boolean) => void> },
'onUpdate:open': { type: [Function, Array] as PropType<(open: boolean) => void> },
onFocus: { type: [Function, Array] as PropType<FocusEventHandler> },
onBlur: { type: [Function, Array] as PropType<FocusEventHandler> },
onMousedown: { type: [Function, Array] as PropType<MouseEventHandler> },
onMouseup: { type: [Function, Array] as PropType<MouseEventHandler> },
onMouseenter: { type: [Function, Array] as PropType<MouseEventHandler> },
onMouseleave: { type: [Function, Array] as PropType<MouseEventHandler> },
onClick: { type: [Function, Array] as PropType<MouseEventHandler> },
onContextmenu: { type: [Function, Array] as PropType<MouseEventHandler> },
onKeydown: {
type: Function as PropType<(event: KeyboardEvent, preventDefault: () => void) => void>,
type: [Function, Array] as PropType<
(event: KeyboardEvent, preventDefault: () => void) => void
>,
},
// WAI-ARIA
role: String,
Expand Down Expand Up @@ -204,18 +210,20 @@ function rangePickerProps<DateType>() {
placeholder: Array,
mode: { type: Array as unknown as PropType<[PanelMode, PanelMode]> },
onChange: {
type: Function as PropType<
type: [Function, Array] as PropType<
(
value: RangeValue<DateType> | RangeValue<string> | null,
dateString: [string, string],
) => void
>,
},
'onUpdate:value': {
type: Function as PropType<(value: RangeValue<DateType> | RangeValue<string> | null) => void>,
type: [Function, Array] as PropType<
(value: RangeValue<DateType> | RangeValue<string> | null) => void
>,
},
onCalendarChange: {
type: Function as PropType<
type: [Function, Array] as PropType<
(
values: RangeValue<DateType> | RangeValue<string>,
formatString: [string, string],
Expand All @@ -224,12 +232,14 @@ function rangePickerProps<DateType>() {
>,
},
onPanelChange: {
type: Function as PropType<
type: [Function, Array] as PropType<
(values: RangeValue<DateType> | RangeValue<string>, modes: [PanelMode, PanelMode]) => void
>,
},
onOk: {
type: Function as PropType<(dates: RangeValue<DateType> | RangeValue<string>) => void>,
type: [Function, Array] as PropType<
(dates: RangeValue<DateType> | RangeValue<string>) => void
>,
},
};
}
Expand Down
6 changes: 3 additions & 3 deletions components/drawer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ export const drawerProps = () => ({
handle: PropTypes.any,
/** @deprecated Use `@afterVisibleChange` instead */
afterVisibleChange: Function as PropType<(visible: boolean) => void>,
onAfterVisibleChange: Function as PropType<(visible: boolean) => void>,
'onUpdate:visible': Function as PropType<(visible: boolean) => void>,
onClose: Function as PropType<MouseEventHandler | KeyboardEventHandler>,
onAfterVisibleChange: [Function, Array] as PropType<(visible: boolean) => void>,
'onUpdate:visible': [Function, Array] as PropType<(visible: boolean) => void>,
onClose: [Function, Array] as PropType<MouseEventHandler | KeyboardEventHandler>,
});

export type DrawerProps = Partial<ExtractPropTypes<ReturnType<typeof drawerProps>>>;
Expand Down
6 changes: 3 additions & 3 deletions components/dropdown/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ const dropdownProps = () => ({
minOverlayWidthMatchTrigger: { type: Boolean, default: undefined },
destroyPopupOnHide: { type: Boolean, default: undefined },
onVisibleChange: {
type: Function as PropType<(val: boolean) => void>,
type: [Function, Array] as PropType<(val: boolean) => void>,
},
'onUpdate:visible': {
type: Function as PropType<(val: boolean) => void>,
type: [Function, Array] as PropType<(val: boolean) => void>,
},
});

Expand All @@ -76,7 +76,7 @@ const dropdownButtonProps = () => ({
title: String,
loading: buttonTypesProps.loading,
onClick: {
type: Function as PropType<MouseEventHandler>,
type: [Function, Array] as PropType<MouseEventHandler>,
},
});

Expand Down
12 changes: 6 additions & 6 deletions components/form/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ export const formProps = () => ({
validateOnRuleChange: { type: Boolean, default: undefined },
// 提交失败自动滚动到第一个错误字段
scrollToFirstError: { type: [Boolean, Object] as PropType<boolean | Options> },
onSubmit: Function as PropType<(e: Event) => void>,
onSubmit: [Function, Array] as PropType<(e: Event) => void>,
name: String,
validateTrigger: { type: [String, Array] as PropType<string | string[]> },
size: { type: String as PropType<SizeType> },
onValuesChange: { type: Function as PropType<Callbacks['onValuesChange']> },
onFieldsChange: { type: Function as PropType<Callbacks['onFieldsChange']> },
onFinish: { type: Function as PropType<Callbacks['onFinish']> },
onFinishFailed: { type: Function as PropType<Callbacks['onFinishFailed']> },
onValidate: { type: Function as PropType<Callbacks['onValidate']> },
onValuesChange: { type: [Function, Array] as PropType<Callbacks['onValuesChange']> },
onFieldsChange: { type: [Function, Array] as PropType<Callbacks['onFieldsChange']> },
onFinish: { type: [Function, Array] as PropType<Callbacks['onFinish']> },
onFinishFailed: { type: [Function, Array] as PropType<Callbacks['onFinishFailed']> },
onValidate: { type: [Function, Array] as PropType<Callbacks['onValidate']> },
});

export type FormProps = Partial<ExtractPropTypes<ReturnType<typeof formProps>>>;
Expand Down
2 changes: 1 addition & 1 deletion components/form/FormItemLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface FormItemLabelProps {
requiredMark?: RequiredMark;
required?: boolean;
prefixCls: string;
onClick: Function;
onClick: [Function, Function[]];
}

const FormItemLabel: FunctionalComponent<FormItemLabelProps> = (props, { slots, emit, attrs }) => {
Expand Down
12 changes: 6 additions & 6 deletions components/input-number/src/InputNumber.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,17 @@ export const inputNumberProps = () => ({
/** Syntactic sugar of `formatter`. Config decimal separator of display. */
decimalSeparator: { type: String as PropType<string> },

onInput: { type: Function as PropType<(text: string) => void> },
onChange: { type: Function as PropType<(value: ValueType) => void> },
onPressEnter: { type: Function as PropType<KeyboardEventHandler> },
onInput: { type: [Function, Array] as PropType<(text: string) => void> },
onChange: { type: [Function, Array] as PropType<(value: ValueType) => void> },
onPressEnter: { type: [Function, Array] as PropType<KeyboardEventHandler> },

onStep: {
type: Function as PropType<
type: [Function, Array] as PropType<
(value: ValueType, info: { offset: ValueType; type: 'up' | 'down' }) => void
>,
},
onBlur: { type: Function as PropType<(e: FocusEvent) => void> },
onFocus: { type: Function as PropType<(e: FocusEvent) => void> },
onBlur: { type: [Function, Array] as PropType<(e: FocusEvent) => void> },
onFocus: { type: [Function, Array] as PropType<(e: FocusEvent) => void> },
});

export default defineComponent({
Expand Down
2 changes: 1 addition & 1 deletion components/input-number/src/StepHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default defineComponent({
prefixCls: String,
upDisabled: Boolean,
downDisabled: Boolean,
onStep: { type: Function as PropType<(up: boolean) => void> },
onStep: { type: [Function, Array] as PropType<(up: boolean) => void> },
},
slots: ['upNode', 'downNode'],
setup(props, { slots, emit }) {
Expand Down
8 changes: 4 additions & 4 deletions components/input/Group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ export default defineComponent({
prefixCls: String,
size: { type: String as PropType<SizeType> },
compact: { type: Boolean, default: undefined },
onMouseenter: { type: Function as PropType<MouseEventHandler> },
onMouseleave: { type: Function as PropType<MouseEventHandler> },
onFocus: { type: Function as PropType<FocusEventHandler> },
onBlur: { type: Function as PropType<FocusEventHandler> },
onMouseenter: { type: [Function, Array] as PropType<MouseEventHandler> },
onMouseleave: { type: [Function, Array] as PropType<MouseEventHandler> },
onFocus: { type: [Function, Array] as PropType<FocusEventHandler> },
onBlur: { type: [Function, Array] as PropType<FocusEventHandler> },
},
setup(props, { slots }) {
const { prefixCls, direction } = useConfigInject('input-group', props);
Expand Down
2 changes: 1 addition & 1 deletion components/input/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default defineComponent({
// 不能设置默认值 https://github.com/vueComponent/ant-design-vue/issues/1916
enterButton: PropTypes.any,
onSearch: {
type: Function as PropType<
type: [Function, Array] as PropType<
(value: string, event?: ChangeEvent | MouseEvent | KeyboardEvent) => void
>,
},
Expand Down
24 changes: 13 additions & 11 deletions components/input/inputProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ const inputProps = () => ({
bordered: { type: Boolean, default: undefined },
showCount: { type: [Boolean, Object] as PropType<boolean | ShowCountProps> },
htmlSize: Number,
onPressEnter: Function as PropType<KeyboardEventHandler>,
onKeydown: Function as PropType<KeyboardEventHandler>,
onKeyup: Function as PropType<KeyboardEventHandler>,
onFocus: Function as PropType<FocusEventHandler>,
onBlur: Function as PropType<FocusEventHandler>,
onChange: Function as PropType<ChangeEventHandler>,
onInput: Function as PropType<ChangeEventHandler>,
'onUpdate:value': Function as PropType<(val: string) => void>,
onPressEnter: [Function, Array] as PropType<KeyboardEventHandler>,
onKeydown: [Function, Array] as PropType<KeyboardEventHandler>,
onKeyup: [Function, Array] as PropType<KeyboardEventHandler>,
onFocus: [Function, Array] as PropType<FocusEventHandler>,
onBlur: [Function, Array] as PropType<FocusEventHandler>,
onChange: [Function, Array] as PropType<ChangeEventHandler>,
onInput: [Function, Array] as PropType<ChangeEventHandler>,
'onUpdate:value': [Function, Array] as PropType<(val: string) => void>,
valueModifiers: Object,
hidden: Boolean,
});
Expand All @@ -95,9 +95,11 @@ const textAreaProps = () => ({
rows: Number,
autosize: { type: [Boolean, Object] as PropType<boolean | AutoSizeType>, default: undefined },
autoSize: { type: [Boolean, Object] as PropType<boolean | AutoSizeType>, default: undefined },
onResize: { type: Function as PropType<(size: { width: number; height: number }) => void> },
onCompositionstart: Function as PropType<CompositionEventHandler>,
onCompositionend: Function as PropType<CompositionEventHandler>,
onResize: {
type: [Function, Array] as PropType<(size: { width: number; height: number }) => void>,
},
onCompositionstart: [Function, Array] as PropType<CompositionEventHandler>,
onCompositionend: [Function, Array] as PropType<CompositionEventHandler>,
valueModifiers: Object,
});

Expand Down
4 changes: 2 additions & 2 deletions components/layout/Sider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ export const siderProps = () => ({
collapsedWidth: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
breakpoint: PropTypes.oneOf(tuple('xs', 'sm', 'md', 'lg', 'xl', 'xxl', 'xxxl')),
theme: PropTypes.oneOf(tuple('light', 'dark')).def('dark'),
onBreakpoint: Function as PropType<(broken: boolean) => void>,
onCollapse: Function as PropType<(collapsed: boolean, type: CollapseType) => void>,
onBreakpoint: [Function, Array] as PropType<(broken: boolean) => void>,
onCollapse: [Function, Array] as PropType<(collapsed: boolean, type: CollapseType) => void>,
});

export type SiderProps = Partial<ExtractPropTypes<ReturnType<typeof siderProps>>>;
Expand Down
Loading