-
Notifications
You must be signed in to change notification settings - Fork 27.2k
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] Wrong @types/react*
default version and build fails if the correct version is installed
#65599
Comments
I suspect it is caused by the name of
|
For now, a workaround is to patch diff --git a/node_modules/next/dist/lib/verify-typescript-setup.js b/node_modules/next/dist/lib/verify-typescript-setup.js
index 23998d8..da91cf4 100644
--- a/node_modules/next/dist/lib/verify-typescript-setup.js
+++ b/node_modules/next/dist/lib/verify-typescript-setup.js
@@ -72,11 +72,6 @@ const requiredPackages = [
pkg: 'typescript',
exportsRestrict: true
},
- {
- file: '@types/react/index.d.ts',
- pkg: '@types/react',
- exportsRestrict: true
- },
{
file: '@types/node/index.d.ts',
pkg: '@types/node',
|
It will work for the most part, but again e.g. // initial value for useRef() is now mandatory for React 19,
// but @types/react@^18 won't complain on that if it's missing
const ref = useRef(null);
// refs are now always mutable in React 19 due to the previous change in API,
// but @types/react@^18 will complain about this line, since refs with initial values are read-only in React 18
ref.current = newValue; |
I guess this is still something that was tackled in #65058 and needs to be to make us able to use react 19 beta in nextjs canary |
Hey @mwskwong typings are now working correctly with nextjs 15 RC and using the following type dependencies: package.json "dependencies": {
"next": "15.0.0-rc.0",
"react": "19.0.0-rc-935180c7e0-20240524",
"react-dom": "19.0.0-rc-935180c7e0-20240524",
},
"devDependencies": {
"@types/react": "npm:types-react@19.0.0-rc.0",
"@types/react-dom": "npm:types-react-dom@19.0.0-rc.0",
}, |
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Link to the code that reproduces this issue
https://github.com/mwskwong/wrong-react-19-types
To Reproduce
next build
and observe the terminal output.Current vs. Expected behavior
Current
When creating a new Next.js project,
types/react@^18
andtypes/react-dom@^18
are used. These types are for React 18, not 19.If we follow https://react.dev/blog/2024/04/25/react-19-upgrade-guide#installing to install the React 19 compatible
@types/react
and@types/react-dom
(already done in the above repo), Next.js will believe@types/react
is not installed when runningnext build
:In CI env, e,g. when deploying on Vercel, the build will straight up fail without the above patching
Expected
Build should be successful.
Provide environment information
Which area(s) are affected? (Select all that apply)
create-next-app, Linting, TypeScript
Which stage(s) are affected? (Select all that apply)
next build (local), Vercel (Deployed)
Additional context
No response
The text was updated successfully, but these errors were encountered: