Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[React 19] The namespace type in @types/react/index.d.ts causes problems. #31817

Open
jin-Pro opened this issue Dec 17, 2024 · 1 comment
Open
Labels

Comments

@jin-Pro
Copy link

jin-Pro commented Dec 17, 2024

Summary

Hello, I am creating a service using monorepo structure via pnpm.

The development environment is as follows:

-pnpm

  • @types/react18
  • @types/react19
  • react18
  • react19

my-monorepo/
├── package.json
├── node_modules/
│ └── .pnpm/
└── apps/
├── project-a/
│ ├── package.json
│ └── node_modules/
│ ├── react/ # React 18
│ │ └── ...
│ └── @types/
│ └── react/ # @types/react 18
└── project-b/
├── package.json
└── node_modules/
├── react/ # React 19
└── @types/
└── react/ # @types/react 19

I am working on a project with the above structure.

A type error related to ReactNode occurs in apps/project-b using react v19.

The cause of the problem I thought was

This problem occurred because the declare namespace React statement declared in index.d.ts inside root/node_modules/@types+react18 and root/node_modules/@types+react19 were merged due to hoist in the package manager. I think.

This is an error caused by the type of react.

Would you recognize this as a problem?


image

image

@eps1lon
Copy link
Collaborator

eps1lon commented Dec 18, 2024

There was a request on the DT repo as well to remove the declare namespace. I don't know if that's safe to do and doesn't cause other breakages. I recommend filing a PR against https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react and see if this is compatible against every other @types/ package. Then we can discuss a rollout plan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants