From 847404b7e31a93d2e1d8e022049a053b235d35d6 Mon Sep 17 00:00:00 2001 From: "jianhu.wang" Date: Thu, 19 Nov 2026 10:48:04 +0800 Subject: [PATCH 1/2] fix(type): make declarations compatible with exactOptionalPropertyTypes Projects with skipLibCheck: false and exactOptionalPropertyTypes failed inside the published declarations: - BaseOptionType members lacked | undefined, so Required (which strips undefined) no longer satisfied the DefaultOptionType constraint (TS2344 x2) (#670). - placement used the indexed access BaseSelectPropsWithoutPrivate['placement'], which includes undefined and is not identical to the inherited member (TS2430) (#671). NonNullable keeps it identical. Type-only change: no difference for projects without the flag. Verified with tsc 6.0.3 and 7.0.2 (strict + exactOptionalPropertyTypes + skipLibCheck: false): all three declaration errors disappear. Suite: 12 suites, 128 tests pass. --- src/Cascader.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Cascader.tsx b/src/Cascader.tsx index f67c9840..095d278b 100644 --- a/src/Cascader.tsx +++ b/src/Cascader.tsx @@ -27,12 +27,14 @@ import { import { formatStrategyValues, toPathOptions } from './utils/treeUtil'; import { warningNullOptions } from './utils/warningPropsUtil'; +// Members carry `| undefined` to stay identical to how `Required` +// strips them under `exactOptionalPropertyTypes` (#670). export interface BaseOptionType { - disabled?: boolean; - disableCheckbox?: boolean; + disabled?: boolean | undefined; + disableCheckbox?: boolean | undefined; label?: React.ReactNode; - value?: string | number | null; - children?: DefaultOptionType[]; + value?: string | number | null | undefined; + children?: DefaultOptionType[] | undefined; } export type DefaultOptionType = BaseOptionType & Record; @@ -117,7 +119,9 @@ interface BaseCascaderProps< popupClassName?: string; popupMenuColumnStyle?: React.CSSProperties; - placement?: BaseSelectPropsWithoutPrivate['placement']; + // NonNullable: the indexed access includes `undefined`, which breaks + // `exactOptionalPropertyTypes` when this interface extends the select props (#671). + placement?: NonNullable; builtinPlacements?: BuildInPlacements; onPopupVisibleChange?: (open: boolean) => void; From 5cb6f84322b144a7cb1e7aaee41de176c0597db8 Mon Sep 17 00:00:00 2001 From: "jianhu.wang" Date: Thu, 19 Nov 2026 10:57:07 +0800 Subject: [PATCH 2/2] fix(type): keep explicit undefined for placement and exclude it from value callbacks - placement: NonNullable removed the undefined that the indexed access carries, so consumers on skipLibCheck: true with exactOptionalPropertyTypes could no longer pass an explicit `placement: 'bottomLeft' | undefined`. Omit 'placement' from the extends clause and keep the indexed access instead. - ValueType: BaseOptionType.value now carries | undefined (#670), which leaked into onChange. Exclude undefined from the derived value type while keeping null, matching the existing callback contract. --- src/Cascader.tsx | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/Cascader.tsx b/src/Cascader.tsx index 095d278b..a0f588c4 100644 --- a/src/Cascader.tsx +++ b/src/Cascader.tsx @@ -74,7 +74,10 @@ interface BaseCascaderProps< ValueField extends keyof OptionType = keyof OptionType, > extends Omit< BaseSelectPropsWithoutPrivate, - 'tokenSeparators' | 'labelInValue' | 'mode' | 'showSearch' + // 'placement' is omitted and redeclared below with the indexed access so + // consumers can still pass explicit `undefined` under + // `exactOptionalPropertyTypes` (#671). + 'tokenSeparators' | 'labelInValue' | 'mode' | 'showSearch' | 'placement' > { // MISC id?: string; @@ -119,9 +122,10 @@ interface BaseCascaderProps< popupClassName?: string; popupMenuColumnStyle?: React.CSSProperties; - // NonNullable: the indexed access includes `undefined`, which breaks - // `exactOptionalPropertyTypes` when this interface extends the select props (#671). - placement?: NonNullable; + // Keep the indexed access (it includes `undefined` under + // `exactOptionalPropertyTypes`) so consumers can still pass an explicit + // undefined; 'placement' is omitted from the extends clause above (#671). + placement?: BaseSelectPropsWithoutPrivate['placement']; builtinPlacements?: BuildInPlacements; onPopupVisibleChange?: (open: boolean) => void; @@ -143,11 +147,16 @@ export interface FieldNames< export type ValueType< OptionType extends DefaultOptionType = DefaultOptionType, ValueField extends keyof OptionType = keyof OptionType, -> = keyof OptionType extends ValueField - ? unknown extends OptionType['value'] - ? OptionType[ValueField] - : OptionType['value'] - : OptionType[ValueField]; +> = Exclude< + keyof OptionType extends ValueField + ? unknown extends OptionType['value'] + ? OptionType[ValueField] + : OptionType['value'] + : OptionType[ValueField], + // BaseOptionType.value carries `| undefined` (#670); a selected value is + // never undefined while `null` stays part of the callback contract. + undefined +>; export type GetValueType< OptionType extends DefaultOptionType = DefaultOptionType,