MenuItemProps cannot extend HTMLAttributes under exactOptionalPropertyTypes

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

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

2026年11月19日 から。

  • #905 @young-tree による — オープン
  • #906 @dreamvrutik による — オープン

評価

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

調査の方向性

lib/interface.d.ts の ItemSharedProps と、lib/MenuItem.d.ts にある競合する宣言から始めます。exactOptionalPropertyTypes と skipLibCheck: false を含む、指定されたコンパイラーオプションで TypeScript 7.0.2 を使ってエラーを再現します。issue では型のみの変更について説明しています。tsc --noEmit を実行して、宣言エラーがなくなったことを確認します。

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

説明

Summary

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

lib/MenuItem.d.ts TS2320 x2: Interface 'MenuItemProps' cannot simultaneously extend types 'Omit<MenuItemType, ...>' and 'Omit<HTMLAttributes, ...>'. Named properties className and style are not identical, because React declares them `?: T

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)

undefined.|In ItemSharedProps(lib/interface.d.ts):style?: React.CSSProperties | undefined; className?: string | undefined`

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

主要言語
TypeScript
スター
700
フォーク
271
平均マージ
1時間 50分
マージ済み PR(30日)
3

環境構築

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

はじめの一歩

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

react-component/menu のほかの issue

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

似ている issue

TypeScript の issue をもっと見る

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

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