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

Bug: React server components give type error in react 19 #28718

Closed
InsightfulFuture opened this issue Apr 2, 2024 · 2 comments
Closed

Bug: React server components give type error in react 19 #28718

InsightfulFuture opened this issue Apr 2, 2024 · 2 comments

Comments

@InsightfulFuture
Copy link

React version:
Canary (19.0.0-canary-95e6f032c-20240401)

Steps To Reproduce

  1. Create a react app with typescript
  2. Make app.tsx a server component

Link to code example:
https://github.com/InsightfulFuture/react-19-ts

The current behavior

I get the error:

'App' cannot be used as a JSX component.
  Its type '() => Promise<JSX.Element>' is not a valid JSX element type.
    Type '() => Promise<JSX.Element>' is not assignable to type '(props: any, deprecatedLegacyContext?: any) => ReactNode'.
      Type 'Promise<Element>' is not assignable to type 'ReactNode'

when I make app an async component with use server

The expected behavior

It works with app as a server component

@InsightfulFuture InsightfulFuture added the Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug label Apr 2, 2024
@pawelblaszczyk5
Copy link

You need to have these versions for it to work correctly typescript@^5.1.2 and @types/react@^18.2.8

@eps1lon
Copy link
Collaborator

eps1lon commented Apr 3, 2024

And enable the types for the Experimental release channel either via an import 'react/experimental' or /// <reference types="react/experimental" /> in at least one file that's part of your TypeScript project.

@eps1lon eps1lon closed this as not planned Won't fix, can't repro, duplicate, stale Apr 3, 2024
@eps1lon eps1lon added Resolution: Support Redirect and removed Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug labels Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants