fix: CascaderProps Multiple boolean type issue (#49669)

* fix: CascaderProps Multiple boolean type issue

* fix: eslint type issue

* Update index.tsx

Signed-off-by: lijianan <574980606@qq.com>

* Update type.test.tsx

Signed-off-by: lijianan <574980606@qq.com>

* Update type.test.tsx

Signed-off-by: lijianan <574980606@qq.com>

* Update index.tsx

Signed-off-by: lijianan <574980606@qq.com>

---------

Signed-off-by: lijianan <574980606@qq.com>
Co-authored-by: lijianan <574980606@qq.com>
This commit is contained in:
Lim Yang Zhi 2024-07-03 10:15:40 +08:00 committed by GitHub
parent a9ad092ef5
commit 3a1a2177b1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 5 deletions

View File

@ -86,12 +86,15 @@ describe('Cascader.typescript', () => {
});
it('multiple onChange', () => {
const { container } = render(<Cascader multiple onChange={(values) => values} />);
const { container } = render(
<Cascader multiple onChange={(values: (string | number | null)[][]) => values} />,
);
expect(container).toBeTruthy();
});
it('props', () => {
const list: { props?: CascaderAutoProps }[] = [
{ props: { multiple: true, onChange: (value) => value } },
{ props: { multiple: true, onChange: (value: (string | number | null)[][]) => value } },
{ props: { multiple: false, onChange: (value) => value } },
];
expect(list).toBeTruthy();

View File

@ -19,13 +19,13 @@ import type { InputStatus } from '../_util/statusUtils';
import { getMergedStatus, getStatusClassNames } from '../_util/statusUtils';
import { devUseWarning } from '../_util/warning';
import { ConfigContext } from '../config-provider';
import type { Variant } from '../config-provider';
import DefaultRenderEmpty from '../config-provider/defaultRenderEmpty';
import DisabledContext from '../config-provider/DisabledContext';
import useCSSVarCls from '../config-provider/hooks/useCSSVarCls';
import useSize from '../config-provider/hooks/useSize';
import type { SizeType } from '../config-provider/SizeContext';
import { FormItemInputContext } from '../form/context';
import type { Variant } from '../config-provider';
import useVariant from '../form/hooks/useVariants';
import mergedBuiltinPlacements from '../select/mergedBuiltinPlacements';
import useSelectStyle from '../select/style';
@ -107,7 +107,7 @@ const defaultSearchRender: ShowSearchType['render'] = (inputValue, path, prefixC
export interface CascaderProps<
OptionType extends DefaultOptionType = DefaultOptionType,
ValueField extends keyof OptionType = keyof OptionType,
Multiple extends boolean = false,
Multiple extends boolean = boolean,
> extends Omit<RcCascaderProps<OptionType, ValueField, Multiple>, 'checkable'> {
multiple?: Multiple;
size?: SizeType;
@ -140,7 +140,7 @@ export type CascaderAutoProps<
ValueField extends keyof OptionType = keyof OptionType,
> =
| CascaderProps<OptionType, ValueField>
| (CascaderProps<OptionType, ValueField, true> & { multiple: true });
| (CascaderProps<OptionType, ValueField, true> & { multiple?: boolean });
export interface CascaderRef {
focus: () => void;