Code Monkey home page Code Monkey logo

Comments (6)

mwskwong avatar mwskwong commented on July 18, 2024 3

For now, a workaround is to patch next to remove its checking on whether @types/react exists during next build. I have to admit this workaround is quite hacky, but it will do the job before a proper fix is landed/React moves types-react back to @types/react.

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',

from next.js.

mwskwong avatar mwskwong commented on July 18, 2024 2

I am using react 19 with next canary 14.3.0-canary.58

  "@types/react": "18.2.74",
  "@types/react-dom": "18.2.23",

You can check the Portfolio and my Repo

It will work for the most part, but again @types/react*@^18 is meant to be used with React 18, not 19. There are some differences in the API between the two versions.

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;

from next.js.

mwskwong avatar mwskwong commented on July 18, 2024

I suspect it is caused by the name of @types/react being changed to types-react in package.json and this affects how resolveFrom works.

export const resolveFrom = (

from next.js.

patelvivekdev avatar patelvivekdev commented on July 18, 2024

I am using react 19 with next canary 14.3.0-canary.58

  "@types/react": "18.2.74",
  "@types/react-dom": "18.2.23",

You can check the Portfolio and my Repo

from next.js.

joaopedrodcf avatar joaopedrodcf commented on July 18, 2024

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

from next.js.

joaopedrodcf avatar joaopedrodcf commented on July 18, 2024

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:[email protected]",
        "@types/react-dom": "npm:[email protected]",
    },

from next.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.