BaseCascaderProps fails TS2430 (placement) under exactOptionalPropertyTypes

オープン 初心者向け
#671 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

@young-tree がすでに取り組んでいます。

2026年11月19日 から。

  • #672 @young-tree による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
react, typescript
領域
frontend, testing

調査の方向性

es/Cascader.d.ts の placement 宣言から始め、@rc-component/select の基底プロパティと比較してください。TypeScript 6.0.3、exactOptionalPropertyTypes: true、skipLibCheck: false で報告された TS2430 を再現してください。これらの設定でそのエラーが発生しなくなれば、issue は完了です。

索引モデルが issue の本文から書いたものです。

説明

With @rc-component/cascader 1.26.0 (resolved by antd 6.7.0), TypeScript 6.0.3, strict, exactOptionalPropertyTypes: true and skipLibCheck: false, the published declaration reports an error on its own (no user code needed):

// index.ts
import type { CascaderProps } from "@rc-component/cascader";
export type Props = CascaderProps;
@rc-component/cascader/es/Cascader.d.ts(25,11): error TS2430: Interface 'BaseCascaderProps<OptionType, ValueField>' incorrectly extends interface 'Omit<BaseSelectPropsWithoutPrivate, "mode" | "showSearch" | "tokenSeparators" | "labelInValue">'.
  Types of property 'placement' are incompatible.
    Type 'Placement | undefined' is not assignable to type 'Placement'.
      Type 'undefined' is not assignable to type 'Placement'.

Cause: es/Cascader.d.ts:58 redeclares placement?: BaseSelectPropsWithoutPrivate['placement'];. Indexed access on the optional base property yields Placement | undefined, while @rc-component/select 1.12.0 declares placement?: Placement. Under exactOptionalPropertyTypes the redeclaration is no longer assignable to the base.

Possible fix: placement?: NonNullable<BaseSelectPropsWithoutPrivate['placement']> (or placement?: Placement).

With exactOptionalPropertyTypes: false the same file compiles with 0 errors. The same declaration file also reports the TS2344 errors tracked in #670.

Versions: @rc-component/cascader 1.26.0, @rc-component/select 1.12.0, antd 6.7.0, TypeScript 6.0.3, @types/react 19.3.0, @types/react-dom 19.3.0, Node 24.21.0.

tsconfig:

{
  "compilerOptions": {
    "target": "ES2024",
    "lib": ["ES2024", "DOM", "DOM.Iterable"],
    "module": "ESNext",
    "moduleResolution": "Bundler",
    "jsx": "react-jsx",
    "strict": true,
    "noUncheckedIndexedAccess": true,
    "exactOptionalPropertyTypes": true,
    "forceConsistentCasingInFileNames": true,
    "isolatedModules": true,
    "verbatimModuleSyntax": true,
    "skipLibCheck": false,
    "noEmit": true,
    "types": ["react", "react-dom"]
  },
  "files": ["index.ts"]
}
主要言語
TypeScript
スター
235
フォーク
153
平均マージ
8分
マージ済み PR(30日)
1

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

react-component/cascader のほかの issue

react-component/cascader の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。