Skip to content

Commit b7d4783

Browse files
author
coffeebi
committed
fix: add array type to event cb props's declaration (vueComponent#5410 vueComponent#5414)
related issue vueComponent#5127 vueComponent#5138
1 parent 02c95d9 commit b7d4783

File tree

15 files changed

+46
-38
lines changed

15 files changed

+46
-38
lines changed

components/button/buttonTypes.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ export const buttonProps = () => ({
3737
target: String,
3838
title: String,
3939
onClick: {
40-
type: Function as PropType<(event: MouseEvent) => void>,
40+
type: [Function, Array] as PropType<(event: MouseEvent) => void>,
4141
},
4242
onMousedown: {
43-
type: Function as PropType<(event: MouseEvent) => void>,
43+
type: [Function, Array] as PropType<(event: MouseEvent) => void>,
4444
},
4545
});
4646

components/card/Card.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const cardProps = () => ({
4242
defaultActiveTabKey: String,
4343
cover: PropTypes.any,
4444
onTabChange: {
45-
type: Function as PropType<(key: string) => void>,
45+
type: [Function, Array] as PropType<(key: string) => void>,
4646
},
4747
});
4848

components/checkbox/interface.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const checkboxGroupProps = () => {
4545
type: [Function, Array] as PropType<(checkedValue: Array<CheckboxValueType>) => void>,
4646
},
4747
'onUpdate:value': {
48-
type: Function as PropType<(checkedValue: Array<CheckboxValueType>) => void>,
48+
type: [Function, Array] as PropType<(checkedValue: Array<CheckboxValueType>) => void>,
4949
},
5050
};
5151
};

components/date-picker/generatePicker/props.ts

+15-7
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ function commonProps<DateType = any>() {
4747
panelRender: { type: Function as PropType<(originPanel: VueNode) => VueNode> },
4848
// // Events
4949
onChange: {
50-
type: Function as PropType<(value: DateType | string | null, dateString: string) => void>,
50+
type: [Function, Array] as PropType<
51+
(value: DateType | string | null, dateString: string) => void
52+
>,
5153
},
5254
'onUpdate:value': {
5355
type: [Function, Array] as PropType<(value: DateType | string | null) => void>,
@@ -64,7 +66,9 @@ function commonProps<DateType = any>() {
6466
onClick: { type: [Function, Array] as PropType<MouseEventHandler> },
6567
onContextmenu: { type: [Function, Array] as PropType<MouseEventHandler> },
6668
onKeydown: {
67-
type: Function as PropType<(event: KeyboardEvent, preventDefault: () => void) => void>,
69+
type: [Function, Array] as PropType<
70+
(event: KeyboardEvent, preventDefault: () => void) => void
71+
>,
6872
},
6973
// WAI-ARIA
7074
role: String,
@@ -206,18 +210,20 @@ function rangePickerProps<DateType>() {
206210
placeholder: Array,
207211
mode: { type: Array as unknown as PropType<[PanelMode, PanelMode]> },
208212
onChange: {
209-
type: Function as PropType<
213+
type: [Function, Array] as PropType<
210214
(
211215
value: RangeValue<DateType> | RangeValue<string> | null,
212216
dateString: [string, string],
213217
) => void
214218
>,
215219
},
216220
'onUpdate:value': {
217-
type: Function as PropType<(value: RangeValue<DateType> | RangeValue<string> | null) => void>,
221+
type: [Function, Array] as PropType<
222+
(value: RangeValue<DateType> | RangeValue<string> | null) => void
223+
>,
218224
},
219225
onCalendarChange: {
220-
type: Function as PropType<
226+
type: [Function, Array] as PropType<
221227
(
222228
values: RangeValue<DateType> | RangeValue<string>,
223229
formatString: [string, string],
@@ -226,12 +232,14 @@ function rangePickerProps<DateType>() {
226232
>,
227233
},
228234
onPanelChange: {
229-
type: Function as PropType<
235+
type: [Function, Array] as PropType<
230236
(values: RangeValue<DateType> | RangeValue<string>, modes: [PanelMode, PanelMode]) => void
231237
>,
232238
},
233239
onOk: {
234-
type: Function as PropType<(dates: RangeValue<DateType> | RangeValue<string>) => void>,
240+
type: [Function, Array] as PropType<
241+
(dates: RangeValue<DateType> | RangeValue<string>) => void
242+
>,
235243
},
236244
};
237245
}

components/dropdown/props.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ const dropdownProps = () => ({
5656
minOverlayWidthMatchTrigger: { type: Boolean, default: undefined },
5757
destroyPopupOnHide: { type: Boolean, default: undefined },
5858
onVisibleChange: {
59-
type: Function as PropType<(val: boolean) => void>,
59+
type: [Function, Array] as PropType<(val: boolean) => void>,
6060
},
6161
'onUpdate:visible': {
62-
type: Function as PropType<(val: boolean) => void>,
62+
type: [Function, Array] as PropType<(val: boolean) => void>,
6363
},
6464
});
6565

@@ -76,7 +76,7 @@ const dropdownButtonProps = () => ({
7676
title: String,
7777
loading: buttonTypesProps.loading,
7878
onClick: {
79-
type: Function as PropType<MouseEventHandler>,
79+
type: [Function, Array] as PropType<MouseEventHandler>,
8080
},
8181
});
8282

components/input-number/src/InputNumber.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export const inputNumberProps = () => ({
7070
onPressEnter: { type: [Function, Array] as PropType<KeyboardEventHandler> },
7171

7272
onStep: {
73-
type: Function as PropType<
73+
type: [Function, Array] as PropType<
7474
(value: ValueType, info: { offset: ValueType; type: 'up' | 'down' }) => void
7575
>,
7676
},

components/input/Search.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default defineComponent({
2323
// 不能设置默认值 https://github.com/vueComponent/ant-design-vue/issues/1916
2424
enterButton: PropTypes.any,
2525
onSearch: {
26-
type: Function as PropType<
26+
type: [Function, Array] as PropType<
2727
(value: string, event?: ChangeEvent | MouseEvent | KeyboardEvent) => void
2828
>,
2929
},

components/mentions/index.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -63,22 +63,22 @@ export const mentionsProps = () => ({
6363
...baseMentionsProps,
6464
loading: { type: Boolean, default: undefined },
6565
onFocus: {
66-
type: Function as PropType<(e: FocusEvent) => void>,
66+
type: [Function, Array] as PropType<(e: FocusEvent) => void>,
6767
},
6868
onBlur: {
69-
type: Function as PropType<(e: FocusEvent) => void>,
69+
type: [Function, Array] as PropType<(e: FocusEvent) => void>,
7070
},
7171
onSelect: {
72-
type: Function as PropType<(option: MentionsOptionProps, prefix: string) => void>,
72+
type: [Function, Array] as PropType<(option: MentionsOptionProps, prefix: string) => void>,
7373
},
7474
onChange: {
75-
type: Function as PropType<(text: string) => void>,
75+
type: [Function, Array] as PropType<(text: string) => void>,
7676
},
7777
onPressenter: {
78-
type: Function as PropType<KeyboardEventHandler>,
78+
type: [Function, Array] as PropType<KeyboardEventHandler>,
7979
},
8080
'onUpdate:value': {
81-
type: Function as PropType<(text: string) => void>,
81+
type: [Function, Array] as PropType<(text: string) => void>,
8282
},
8383
notFoundContent: PropTypes.any,
8484
defaultValue: String,

components/switch/index.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,19 @@ export const switchProps = () => ({
3434
PropTypes.looseBool,
3535
]).def(false),
3636
onChange: {
37-
type: Function as PropType<(checked: CheckedType, e: Event) => void>,
37+
type: [Function, Array] as PropType<(checked: CheckedType, e: Event) => void>,
3838
},
3939
onClick: {
40-
type: Function as PropType<(checked: CheckedType, e: Event) => void>,
40+
type: [Function, Array] as PropType<(checked: CheckedType, e: Event) => void>,
4141
},
4242
onKeydown: {
43-
type: Function as PropType<(e: Event) => void>,
43+
type: [Function, Array] as PropType<(e: Event) => void>,
4444
},
4545
onMouseup: {
46-
type: Function as PropType<(e: Event) => void>,
46+
type: [Function, Array] as PropType<(e: Event) => void>,
4747
},
4848
'onUpdate:checked': {
49-
type: Function as PropType<(checked: CheckedType) => void>,
49+
type: [Function, Array] as PropType<(checked: CheckedType) => void>,
5050
},
5151
onBlur: [Function, Array] as PropType<FocusEventHandler>,
5252
onFocus: [Function, Array] as PropType<FocusEventHandler>,

components/table/Table.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,11 @@ export const tableProps = () => {
153153
expandIcon: { type: Function as PropType<TableProps['expandIcon']>, default: undefined },
154154
onExpand: { type: [Function, Array] as PropType<TableProps['onExpand']>, default: undefined },
155155
onExpandedRowsChange: {
156-
type: Function as PropType<TableProps['onExpandedRowsChange']>,
156+
type: [Function, Array] as PropType<TableProps['onExpandedRowsChange']>,
157157
default: undefined,
158158
},
159159
'onUpdate:expandedRowKeys': {
160-
type: Function as PropType<TableProps['onExpandedRowsChange']>,
160+
type: [Function, Array] as PropType<TableProps['onExpandedRowsChange']>,
161161
default: undefined,
162162
},
163163
defaultExpandAllRows: {
@@ -194,7 +194,7 @@ export const tableProps = () => {
194194
locale: { type: Object as PropType<TableLocale>, default: undefined },
195195

196196
onChange: {
197-
type: Function as PropType<
197+
type: [Function, Array] as PropType<
198198
(
199199
pagination: TablePaginationConfig,
200200
filters: Record<string, FilterValue | null>,
@@ -205,7 +205,7 @@ export const tableProps = () => {
205205
default: undefined,
206206
},
207207
onResizeColumn: {
208-
type: Function as PropType<(w: number, col: ColumnType) => void>,
208+
type: [Function, Array] as PropType<(w: number, col: ColumnType) => void>,
209209
default: undefined,
210210
},
211211
rowSelection: { type: Object as PropType<TableRowSelection>, default: undefined },

components/tabs/src/TabNavList/TabNode.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default defineComponent({
3232
editable: { type: Object as PropType<EditableConfig> },
3333
onClick: { type: [Function, Array] as PropType<(e: MouseEvent | KeyboardEvent) => void> },
3434
onResize: {
35-
type: Function as PropType<
35+
type: [Function, Array] as PropType<
3636
(width: number, height: number, left: number, top: number) => void
3737
>,
3838
},

components/tabs/src/TabNavList/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const tabNavListProps = () => {
4545
renderTabBar: { type: Function as PropType<RenderTabBar> },
4646
locale: { type: Object as PropType<TabsLocale>, default: undefined as TabsLocale },
4747
onTabClick: {
48-
type: Function as PropType<(activeKey: Key, e: MouseEvent | KeyboardEvent) => void>,
48+
type: [Function, Array] as PropType<(activeKey: Key, e: MouseEvent | KeyboardEvent) => void>,
4949
},
5050
onTabScroll: { type: [Function, Array] as PropType<OnTabScroll> },
5151
};

components/tabs/src/Tabs.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ export const tabsProps = () => {
5555
size: { type: String as PropType<SizeType> },
5656
centered: Boolean,
5757
onEdit: {
58-
type: Function as PropType<
58+
type: [Function, Array] as PropType<
5959
(e: MouseEvent | KeyboardEvent | Key, action: 'add' | 'remove') => void
6060
>,
6161
},
6262
onChange: { type: [Function, Array] as PropType<(activeKey: Key) => void> },
6363
onTabClick: {
64-
type: Function as PropType<(activeKey: Key, e: KeyboardEvent | MouseEvent) => void>,
64+
type: [Function, Array] as PropType<(activeKey: Key, e: KeyboardEvent | MouseEvent) => void>,
6565
},
6666
onTabScroll: { type: [Function, Array] as PropType<OnTabScroll> },
6767
'onUpdate:activeKey': { type: [Function, Array] as PropType<(activeKey: Key) => void> },

components/tag/CheckableTag.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ const checkableTagProps = () => ({
77
prefixCls: String,
88
checked: { type: Boolean, default: undefined },
99
onChange: {
10-
type: Function as PropType<(checked: boolean) => void>,
10+
type: [Function, Array] as PropType<(checked: boolean) => void>,
1111
},
1212
onClick: {
13-
type: Function as PropType<(e: MouseEvent) => void>,
13+
type: [Function, Array] as PropType<(e: MouseEvent) => void>,
1414
},
1515
'onUpdate:checked': [Function, Array] as PropType<(checked: boolean) => void>,
1616
});

components/tag/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const tagProps = () => ({
2222
closeIcon: PropTypes.any,
2323
visible: { type: Boolean, default: undefined },
2424
onClose: {
25-
type: Function as PropType<(e: MouseEvent) => void>,
25+
type: [Function, Array] as PropType<(e: MouseEvent) => void>,
2626
},
2727
'onUpdate:visible': [Function, Array] as PropType<(vis: boolean) => void>,
2828
icon: PropTypes.any,

0 commit comments

Comments
 (0)