solidjs / solid-router

A universal router for Solid inspired by Ember and React Router
MIT License
1.13k stars 143 forks source link

`<Router>` is not assignable to type 'Element' #317

Closed Borber closed 8 months ago

Borber commented 9 months ago

Describe the bug

Source File: https://github.com/Borber/tran/blob/master/src/index.tsx

Written according to the official example, vscode reports an error, but it can be compiled and the behavior is as expected

Type '{ path: string; component: (() => Element) & { preload: () => Promise<{ default: () => Element; }>; }; }[]' is not assignable to type 'Element'.
  Type '{ path: string; component: (() => Element) & { preload: () => Promise<{ default: () => Element; }>; }; }[]' is not assignable to type 'ArrayElement'.
    Type '{ path: string; component: (() => JSX.Element) & { preload: () => Promise<{ default: () => JSX.Element; }>; }; }' is not assignable to type 'Element'.ts(2322)
components.d.ts(6, 5): The expected type comes from property 'children' which is declared here on type 'IntrinsicAttributes & BaseRouterProps & { url?: string | undefined; actionBase?: string | undefined; explicitLinks?: boolean | undefined; preload?: boolean | undefined; }'
[Codeium: Explain Problem](vscode-file://vscode-app/c:/Users/BORBER/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html)

const routes: {
    path: string;
    component: (() => JSX.Element) & {
        preload: () => Promise<{
            default: () => JSX.Element;
        }>;
    };
}[]

Your Example Website or App

https://github.com/Borber/tran/blob/master/src/index.tsx

Steps to Reproduce the Bug or Issue

Edit with vscode

Expected behavior

As expected, but the editor reported an error

Screenshots or Videos

image

Platform

Additional context

No response

ryansolid commented 8 months ago

Fixed in 0.10.2