dai-shi / waku

⛩️ The minimal React framework
https://waku.gg
MIT License
4.64k stars 124 forks source link

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

Open rmarscher opened 4 days ago

rmarscher commented 4 days ago

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 commented 3 days ago

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

Can anyone look into it?