SinglePickerPanelProps incorrectly extends BasePickerPanelProps under exactOptionalPropertyTypes

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

まだ誰も着手していません。

評価

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

調査の方向性

lib/PickerPanel/index.d.ts の宣言から始め、SinglePickerPanelProps が BasePickerPanelProps をどのように継承し、defaultValue を宣言しているかを確認してください。issue で提案されている型だけの変更を適用し、その後、strict と exactOptionalPropertyTypes を有効にし、skipLibCheck を無効にして tsc --noEmit を実行してください。パッケージの宣言が TS2430 なしでコンパイルされ、そのフラグを使わない利用者に対して props が変更されていなければ完了です。

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

説明

Summary

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

lib/PickerPanel/index.d.ts TS2430: Interface 'SinglePickerPanelProps' incorrectly extends interface 'BasePickerPanelProps'. Types of property 'defaultValue' are incompatible: it is redeclared as DateType | null over the inherited SharedTimeProps.defaultValue?: DateType.

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)

export interface SinglePickerPanelProps<DateType extends object = any> extends Omit<BasePickerPanelProps<DateType>, 'defaultValue'>. The resulting props are unchanged, since the interface redeclares defaultValue itself.

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

主要言語
TypeScript
スター
306
フォーク
356
平均マージ
1時間 42分
マージ済み PR(30日)
1

環境構築

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

はじめの一歩

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

react-component/picker のほかの issue

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

似ている issue

TypeScript の issue をもっと見る

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

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