solidjs / solid-router

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

Route component props.path is wrongly typed #131

Closed JensForstmann closed 2 years ago

JensForstmann commented 2 years ago

Describe the bug

The path prop of the Route component is wrongly typed as path: string.

I'd expect it typed as path: string | string[] as in RouteDefinition.

Compare https://github.com/solidjs/solid-app-router/blob/d4de2f857894e1a534db6d6701e4b46db7e7d35b/src/components.tsx#L149-L150 to https://github.com/solidjs/solid-app-router/blob/d4de2f857894e1a534db6d6701e4b46db7e7d35b/src/types.ts#L56-L57

Your Example Website or App

https://stackblitz.com/edit/vitejs-vite-ucupp1?file=src%2Fmain.tsx

Steps to Reproduce the Bug or Issue

import { render } from 'solid-js/web';
import { Router, Route, Routes } from "solid-app-router";
render(
    () => (
        <Router>
            <Routes>
                <Route path="/" element={<></>} />
                <Route path={["/", "/home"]} element={<></>} /> {/* <<-- Error here: Type 'string[]' is not assignable to type 'string'.*/}
            </Routes>
        </Router>
    ),
    document.getElementById('root') as HTMLElement
);

Expected behavior

I'd expect it typed as path: string | string[] as in RouteDefinition.

Screenshots or Videos

No response

Platform

Additional context

No response

JensForstmann commented 2 years ago

Fix got merged in #135