`@types/react@^18` in `dependencies` breaks type-checking in React 19 projects
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 50/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- react, typescript
- Domain
- build-system
Research direction
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.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- TypeScript
- Stars
- 28
- Forks
- 15
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 70
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from braintrustdata/braintrust-sdk-javascript
-
typescript
Difficulty 4/5 3-5 days Newbie friendliness 55/100
braintrustdata/braintrust-sdk-javascript#2578 ·
Maintainers usually reply within 1 day
-
typescript
Difficulty 4/5 3-5 days Newbie friendliness 55/100
braintrustdata/braintrust-sdk-javascript#2577 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
braintrustdata/braintrust-sdk-javascript#2527 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 65/100
braintrustdata/braintrust-sdk-javascript#2526 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 56/100
braintrustdata/braintrust-sdk-javascript#2482 ·
Maintainers usually reply within 1 day
All issues in braintrustdata/braintrust-sdk-javascript
Similar issues
-
bug confirmed perf
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
videojs/video.js#9400 · 1 comment ·
Maintainers usually reply within 1 day
-
good first issue hacktoberfest
Difficulty 2/5 Half a day Newbie friendliness 70/100
HelpCode-ai/anythingmcp#996 ·
Maintainers usually reply within 1 day
-
check:passed streams:add
Difficulty 1/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 2 days
-
beta technical-medium ui
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
walletbeat/walletbeat#1625 ·
Maintainers usually reply within 1 day
-
[Good First Issue]: Add unit tests for NetworkVersionInfoPossibly taken A pull request linked to this issue is open or already merged. OpenGood First Issue hacktoberfest
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
hiero-ledger/hiero-sdk-js#4489 ·
Maintainers usually reply within 1 day