vercel / next.js

The React Framework
https://nextjs.org
MIT License
127.52k stars 27.04k forks source link

Type error: Namespace 'React' has no exported member 'PromiseLikeOfReactNode'. #72555

Open smessmer opened 3 weeks ago

smessmer commented 3 weeks ago

Link to the code that reproduces this issue

https://github.com/cryfs/cryfs-web-next/tree/feature/failing

To Reproduce

  1. Clone repository from above link, in the specified branch
  2. Run "npm run build" (which will run next build)

Current vs. Expected behavior

With next.js 13.5.4, everything works fine. But when upgrading to next.js 13.5.5, (this commit), it breaks and shows:

./node_modules/next/dist/client/components/error-boundary.d.ts:26:71
Type error: Namespace 'React' has no exported member 'PromiseLikeOfReactNode'.

  24 |     static getDerivedStateFromProps(props: ErrorBoundaryHandlerProps, state: ErrorBoundaryHandlerState): ErrorBoundaryHandlerState | null;
  25 |     reset: () => void;
> 26 |     render(): string | number | boolean | React.ReactFragment | React.PromiseLikeOfReactNode | React.JSX.Element | null | undefined;
     |                                                                       ^
  27 | }
  28 | export declare function GlobalError({ error }: {
  29 |     error: any;

The update of the next.js version is the only change in that commit, so this seems to be a breaking change in a minor version.

How can I fix this? Ideally without upgrading next.js since we're not ready to go to Next.js 14 yet. The latest minor version on next.js 13 (13.5.7) still has the issue.

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #47-Ubuntu SMP PREEMPT_DYNAMIC Fri Sep 27 21:40:26 UTC 2024
Binaries:
  Node: 18.19.1
  npm: 10.9.0
  Yarn: 1.22.19
  pnpm: N/A
Relevant Packages:
  next: 13.5.5
  eslint-config-next: 13.5.5
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.0.4
Next.js Config:
  output: export

Which area(s) are affected? (Select all that apply)

Not sure

Which stage(s) are affected? (Select all that apply)

next build (local)

Additional context

works in 13.5.5-canary.2 broken in 13.5.5-canary.3

smessmer commented 3 weeks ago

We actually did end up moving to next.js 14 and that seems to solve it, but leaving this issue here for others who are stuck on next.js 13