Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

`@types/react@^18` in `dependencies` breaks type-checking in React 19 projects

Cerrado
#2,594 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
50/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
react, typescript
Área
build-system

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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/react in 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.

Lenguaje dominante
TypeScript
Estrellas
29
Forks
16
Merge medio
1 d 19 h
PR fusionados (30 d)
69

Preparar el entorno

  • Incluye un Dockerfile o un archivo de Docker Compose
  • Sin plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de braintrustdata/braintrust-sdk-javascript

Todos los issues de braintrustdata/braintrust-sdk-javascript

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.