diff --git a/components/cascader/__tests__/type.test.tsx b/components/cascader/__tests__/type.test.tsx index dce62fdf18..7a16385ef3 100644 --- a/components/cascader/__tests__/type.test.tsx +++ b/components/cascader/__tests__/type.test.tsx @@ -74,4 +74,18 @@ describe('Cascader.typescript', () => { ); expect(wrapper).toBeTruthy(); }); + + it('single onChange', () => { + const wrapper = mount( + values} />, + ); + expect(wrapper).toBeTruthy(); + }); + + it('multiple onChange', () => { + const wrapper = mount( + values} />, + ); + expect(wrapper).toBeTruthy(); + }); }); diff --git a/components/cascader/index.tsx b/components/cascader/index.tsx index f38029f626..2269820a1a 100644 --- a/components/cascader/index.tsx +++ b/components/cascader/index.tsx @@ -2,7 +2,8 @@ import * as React from 'react'; import classNames from 'classnames'; import RcCascader from 'rc-cascader'; import type { - CascaderProps as RcCascaderProps, + SingleCascaderProps as RcSingleCascaderProps, + MultipleCascaderProps as RcMultipleCascaderProps, ShowSearchType, FieldNames, BaseOptionType, @@ -80,8 +81,16 @@ const defaultSearchRender: ShowSearchType['render'] = (inputValue, path, prefixC return optionList; }; -export interface CascaderProps - extends Omit { +type SingleCascaderProps = Omit & { + multiple?: false; +}; +type MultipleCascaderProps = Omit & { + multiple: true; +}; + +type UnionCascaderProps = SingleCascaderProps | MultipleCascaderProps; + +export type CascaderProps = UnionCascaderProps & { multiple?: boolean; size?: SizeType; bordered?: boolean;