`@types/react@^18` in `dependencies` breaks type-checking in React 19 projects
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 50/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- react, typescript
- 领域
- build-system
调研方向
The problem is the @types/react entry under dependencies in the braintrust package manifest, added with #2191 for the braintrust/custom-views typings in dist/custom-views.d.ts. Read the manifest and check whether custom views need React types at all. The suggested fix moves @types/react to an optional peer dependency, which is a maintainer decision, so confirm the approach before editing. Done means a React 19 project installs no React 18 types, and custom-views consumers still type-check.
由索引模型根据 Issue 内容生成。
描述
Summary
Since 3.33.0, braintrust lists @types/react: ^18.3.1 under dependencies. As far as I can tell it is only needed for the braintrust/custom-views type definitions (dist/custom-views.d.ts imports ReactNode from react), which came in with #2191.
Because it is a hard dependency, every consumer gets React 18 types installed, including projects that don't use custom views or don't use React at all. In a React 19 project, this can break tsc.
What happened
We use pnpm (workspace) and React 19 (@types/react@19). After upgrading braintrust from 3.32.0 to 3.35.0, pnpm hoisted @types/[email protected] into node_modules/.pnpm/node_modules. Packages that import types from react without declaring @types/react themselves (in our case @sentry/react) then resolved React 18 types, while our own code used React 19 types. tsc --noEmit failed with errors like this:
error TS2322: Type 'React.ReactNode' is not assignable to type 'import(".../@[email protected]/node_modules/@types/react/index").ReactNode'.
Type 'ReactElement<unknown, string | JSXElementConstructor<any>>' is not assignable to type 'ReactNode'.
Property 'children' is missing in type 'ReactElement<unknown, string | JSXElementConstructor<any>>' but required in type 'ReactPortal'.
We work around it with a pnpm override ("braintrust>@types/react": "^19"), or by staying on 3.32.0.
Versions
braintrust: 3.33.0 – 3.37.1 (not in 3.32.0)@types/reactin the project: 19.2.x- Package manager: pnpm 11 (workspace)
Suggestion
Declare @types/react (and react, if needed) as an optional peer dependency, for example:
"peerDependencies": {
"@types/react": ">=18"
},
"peerDependenciesMeta": {
"@types/react": { "optional": true }
}
That way, projects that use custom views get the @types/react they already have, whatever its version, and other projects don't get React types installed at all.
- 主要语言
- TypeScript
- 星标
- 29
- 派生
- 16
- 平均合并
- 1 天 22 小时
- 30 天内合并 PR
- 72
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
braintrustdata/braintrust-sdk-javascript 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 22/100
braintrustdata/braintrust-sdk-javascript#2624 · 1 条评论 ·
维护者通常 1 天内回复
-
typescript
难度 4/5 3-5 天 新手友好度 55/100
braintrustdata/braintrust-sdk-javascript#2578 ·
维护者通常 1 天内回复
-
[bot] Instrument Letta Agent SDK (87,205 weekly downloads)可能已有人在做 @karthiksenv 于 2 天前认领。 未关闭typescript
难度 4/5 3-5 天 新手友好度 55/100
braintrustdata/braintrust-sdk-javascript#2577 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 55/100
braintrustdata/braintrust-sdk-javascript#2527 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 65/100
braintrustdata/braintrust-sdk-javascript#2526 ·
维护者通常 1 天内回复
查看 braintrustdata/braintrust-sdk-javascript 的全部 Issue
相似的 Issue
-
fix(frontend): correct VITE_IS_DEVELPOMENT typo in shared/app.ts and align dev environment flags未关闭
难度 2/5 1-3 小时 新手友好度 75/100
vicharanashala/ajrasakha#1439 ·
维护者通常 1 天内回复
-
approved check:passed streams:add
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 70/100
codex-team/editor.js#3037 ·
-
complexity: trivial good first issue impact: low
难度 1/5 1 小时以内 新手友好度 78/100
ueberdosis/tiptap#8522 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
wormhole-foundation/wormhole#5062 ·
维护者通常 1 天内回复