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 摘要。