BaseOptionType fails Required<OptionType> constraint under exactOptionalPropertyTypes

Aberta Para iniciantes
#670 2 comentários 0 reações 0 responsáveis Ver no GitHub

@young-tree já está trabalhando nisso.

Desde 19/11/2026.

  • #672 de @young-tree — aberto

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
78/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
react, typescript
Domínio
frontend

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
TypeScript
Estrelas
235
Forks
153
Merge médio
8min
PRs com merge (30d)
1

Preparar o ambiente

Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de react-component/cascader

Todas as issues de react-component/cascader

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.