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

Typescript error with Root and Slot and React 19.x types #996

Open
rmarscher opened this issue Nov 10, 2024 · 1 comment
Open

Typescript error with Root and Slot and React 19.x types #996

rmarscher opened this issue Nov 10, 2024 · 1 comment

Comments

@rmarscher
Copy link
Contributor

With the React 19.x types package, Root and Slot cause tsc errors:

  "devDependencies": {
    "@types/react": "npm:types-react@rc",
    "@types/react-dom": "npm:types-react-dom@rc",
    "typescript": "5.6.3"
  }

Error:

src/entries.tsx:12:56 - error TS2786: 'Slot' cannot be used as a JSX component.
  Its type '({ id, children, fallback, unstable_shouldRenderPrev, }: { id: string; children?: ReactNode; fallback?: ReactNode; unstable_shouldRenderPrev?: (err: unknown) => boolean; }) => CElement<OuterSlotProps, OuterSlot>' is not a valid JSX element type.
    Type '({ id, children, fallback, unstable_shouldRenderPrev, }: { id: string; children?: ReactNode; fallback?: ReactNode; unstable_shouldRenderPrev?: (err: unknown) => boolean; }) => CElement<OuterSlotProps, OuterSlot>' is not assignable to type '(props: any) => ReactNode'.
      Type 'CElement<OuterSlotProps, OuterSlot>' is not assignable to type 'ReactNode'.
        Property 'children' is missing in type 'ComponentElement<OuterSlotProps, OuterSlot>' but required in type 'ReactPortal'.

12       return renderHtml({ App: <App name="Waku" /> }, <Slot id="App" />, '');
                                                          ~~~~

  ../../node_modules/.pnpm/types-react@19.0.0-rc.1/node_modules/types-react/index.d.ts:389:9
    389         children: ReactNode;
                ~~~~~~~~
    'children' is declared here.

The <Root> error in main.tsx is similar.

@dai-shi
Copy link
Owner

dai-shi commented Nov 11, 2024

Slot has children?: ReactNode; type, so I wonder where children: ReactNode; exists.

Can anyone look into it?

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

No branches or pull requests

2 participants