BaseOptionType fails Required<OptionType> constraint under exactOptionalPropertyTypes

Offen Anfängerfreundlich
#670 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

@young-tree arbeitet bereits daran.

Seit 19.11.2026.

  • #672 von @young-tree — offen

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
78/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
react, typescript
Bereich
frontend

Rechercherichtung

Start with BaseOptionType in the package declarations and inspect how its optional properties interact with Required<OptionType> in GetValueType. Reproduce the declaration errors using TypeScript 7.0.2 with exactOptionalPropertyTypes enabled and skipLibCheck disabled. Update the affected optional property types as described, then confirm tsc --noEmit passes with the repro configuration.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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.

Vorherrschende Sprache
TypeScript
Sterne
235
Forks
153
Ø Merge
8 Min.
Gemergte PRs (30 T.)
1

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus react-component/cascader

Alle Issues in react-component/cascader

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.