MenuItemProps cannot extend HTMLAttributes under exactOptionalPropertyTypes

未關閉 適合新手
#904 2 則留言 0 個 reaction 已指派 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 中互相衝突的宣告開始。使用 TypeScript 7.0.2 和列出的編譯器選項(包括 exactOptionalPropertyTypes 和 skipLibCheck: false)重現錯誤。該 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 分鐘
30 天內合併 PR
3

環境準備

這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

react-component/menu 的其他 Issue

查看 react-component/menu 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。