Declare @types/react as an optional peer dependency
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 76/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- react, typescript
调研方向
首先检查 react-aria-components、react-aria、react-stately 和 @react-types/shared 的包清单中的 peerDependencies 和 peerDependenciesMeta,然后比较它们现有的 React peer 范围。为受影响的包添加可选的 @types/react peer 元数据,并验证清单和生成的包元数据都包含该信息。完成标准是:这些包声明了可选 peer,且提供的 TypeScript 解析复现能够正确解析 React 类型。
由索引模型根据 Issue 内容生成。
描述
Summary
react-aria-components, react-aria, react-stately, @react-types/shared ship type declarations that import from react but don't declare @types/react.
With an install layout where packages live outside the project, such as pnpm's global virtual store (virtualStoreType: global), TypeScript resolves react from the package's real path. The react peer is linked next to the package, @types/react is not, so TypeScript picks the untyped react/index.js and every React type in these declarations silently becomes any.
Consumers see it as errors in their own code, for example TS7006: Parameter 'x' implicitly has an 'any' type on callback parameters, or component props that lose children and className. Under pnpm's default layout it only works through pnpm's hidden hoisting fallback (node_modules/.pnpm/node_modules).
Affected versions: [email protected], [email protected], [email protected], @react-types/[email protected]
Reproduction
pnpm 12.18.0:
mkdir repro && cd repro
echo '{ "name": "repro", "private": true }' > package.json
echo 'virtualStoreType: global' > pnpm-workspace.yaml
pnpm add react-aria-components react react-dom @types/react typescript
echo 'import "react-aria-components";' > index.ts
pnpm exec tsc --noEmit --traceResolution --module esnext --moduleResolution bundler --jsx react-jsx index.ts | grep "Module name 'react' was"
Expected: react resolves to @types/react/index.d.ts.
Actual: .../pnpm/store/v11/links/@/react/<version>/<hash>/node_modules/react/index.js
Suggested fix
"peerDependencies": {
"@types/react": "*"
},
"peerDependenciesMeta": {
"@types/react": { "optional": true }
}
Optional, so JavaScript consumers are unaffected. The range can mirror the existing react peer range. react-router, @tanstack/react-query and recharts (recharts#7710) do the same.
Consumer-side workarounds until then: pnpm's addMissingPeerTypes (pnpm 12.12+) or packageExtensions. Related: pnpm/pnpm#9739.
- 主要语言
- TypeScript
- 星标
- 16k
- 派生
- 1.6k
- 平均合并
- 4 天 3 小时
- 30 天内合并 PR
- 39
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
adobe/react-spectrum 的其他 Issue
-
@internationalized/number: NumberParser misparses Arabic-digit numbers that use . , or ، (sd parses ١٬٢٣٤.٥ as 12345)可能已有人在做 @itsrayeedscodespace 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
adobe/react-spectrum#10936 · 3 条评论 ·
维护者通常 1 天内回复
-
PreviewTrigger: the preview dialog has no accessible name可能已有人在做 @therealemmanueloppong 于 3 天前认领。 未关闭accessibility bug PreviewTrigger
难度 2/5 1-3 小时 新手友好度 76/100
adobe/react-spectrum#10917 · 3 条评论 ·
维护者通常 1 天内回复
-
S2 quiet Picker menu is always 192px wide: its width calc() has no unit可能已有人在做 @darshpatel1052 于 5 天前认领。 未关闭waiting on author
难度 2/5 1 小时以内 新手友好度 88/100
adobe/react-spectrum#10909 · 3 条评论 ·
维护者通常 1 天内回复
-
DatePicker omits timezone for initially empty fields despite zoned placeholderValue可能已有人在做 @mrlexcoder 于 6 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 68/100
adobe/react-spectrum#10900 · 2 条评论 ·
维护者通常 1 天内回复
-
Separator adds a redundant role="separator" to its default <hr>可能已有人在做 @Janani-bn 于 6 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 74/100
adobe/react-spectrum#10894 · 2 条评论 ·
维护者通常 1 天内回复
查看 adobe/react-spectrum 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 73/100
维护者通常 1 天内回复
-
area/admin/user area/internationalization automated-triage issue/auto-triaged type/bug
难度 1/5 1 小时以内 新手友好度 76/100
grafana/grafana#137281 · 1 条评论 ·
维护者通常 1 天内回复
-
accessibility bug
难度 2/5 1-3 小时 新手友好度 79/100
Luen/crag-stats#429 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
维护者通常 1 天内回复
-
Missing assertions to legacy Cafe Menu block tests可能已有人在做 @mariamanbar 今天认领。 未关闭
难度 1/5 1 小时以内 新手友好度 90/100
freeCodeCamp/freeCodeCamp#71624 ·
维护者通常 1 天内回复