Skip to content

BaseOptionType fails Required<OptionType> constraint under exactOptionalPropertyTypes #670

Open

Description

@saosebastiao

Summary

rc-cascader 3.33.1–3.34.0, with TypeScript 7.0.2, "strict": true, "exactOptionalPropertyTypes": true, "skipLibCheck": false: its declarations report errors themselves (no error in user code is needed).

lib/Cascader.d.ts TS2344 x2 in GetValueType: Required<OptionType> does not satisfy the constraint 'DefaultOptionType'. Required<> strips undefined from disabled?: boolean (and disableCheckbox), and under the flag OptionType['disabled'] (which still includes undefined via the generic) is then not assignable to boolean.

Repro

{ "compilerOptions": { "strict": true, "exactOptionalPropertyTypes": true, "skipLibCheck": false,
  "jsx": "react-jsx", "module": "esnext", "moduleResolution": "bundler", "noEmit": true } }

Import the package (or the antd 5 component that uses it) and run tsc --noEmit.

Fix (type-only; identical for consumers without the flag)

In BaseOptionType: disabled?: boolean | undefined; disableCheckbox?: boolean | undefined; value?: string | number | null | undefined; children?: DefaultOptionType[] | undefined

We run this as a local patch with no other changes. Happy to open a PR.

Activity

  1. VishnuPatel9009 commented on Nov 17, 2026

    @VishnuPatel9009

    Confirming the same TS2344 on the current @rc-component/cascader line, not only rc-cascader 3.x:

    • @rc-component/cascader 1.26.0 (resolved by antd 6.7.0), TypeScript 6.0.3, @types/react 19.3.0, strict, exactOptionalPropertyTypes: true, skipLibCheck: false, moduleResolution: "Bundler".
    • Repro: import type { CascaderProps } from "@rc-component/cascader";
    @rc-component/cascader/es/Cascader.d.ts(70,229): error TS2344: Type 'Required<OptionType>' does not satisfy the constraint 'DefaultOptionType'.
      Type 'Required<OptionType>' is not assignable to type 'BaseOptionType'.
        Types of property 'disabled' are incompatible.
          Type 'OptionType["disabled"]' is not assignable to type 'boolean'.
            Type 'boolean | undefined' is not assignable to type 'boolean'.
              Type 'undefined' is not assignable to type 'boolean'.
    

    The identical error is also reported at (70,277). With exactOptionalPropertyTypes: false the file compiles with 0 errors. The same declaration file also fails TS2430 on placement, filed separately as #671.

  2. young-tree commented on Nov 19, 2026

    @young-tree

    Opened #672 with the suggested member widening (disabled/disableCheckbox/value/children gain | undefined), plus the placement TS2430 from #671 (NonNullable). Verified with tsc 7.0.2 and 6.0.3 under strict + exactOptionalPropertyTypes + skipLibCheck: false — all three declaration errors disappear; suite 128 tests pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions