-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Which project does this relate to?
Router
Describe the bug
In the linked example the browser expects the path to be /about/ but TS thinks it should be /about
(Note: the slash vs no slash at the end of the string)
This causes a TS error if you do what the browser needs and it causes a JS error (or at least unexpected behavior) if you do what TS thinks is correct.
Your Example Website or App
https://stackblitz.com/edit/github-ytjdgxla?file=src%2Fcomponents%2FNav.tsx
Steps to Reproduce the Bug or Issue
- Create a blank tanstack start app
- Create a folder structure like
src>routes>parentRoute - In
parentRoutestore anindex.tsxfile and achildRoute.tsxfile - Create a
RoutePathtype usingtype RoutePath = RootRouteChildren[keyof RootRouteChildren]['fullPath'] - Create
routePathsvariable with typeArray<RoutePath> - Filter
routeTree.childrenlooking for matchingfullPathproperties with the route path items in the array
You will fins that the routeTree.children fullPath properties do not align with the RoutePath type.
Expected behavior
RootRouteChildren[keyof RootRouteChildren]['fullPath'] should match the values that the browser actually provides.
In this case, I think the browser is the one in the wrong since it has inconsistent use of the end slash (final destinations have no end slash, parent destinations do have an end slash). I think both parent and final destinations should have no end slash for consistency.
Screenshots or Videos
Platform
- Router / Start Version: 1.130.2
- OS: Windows 11
- Browser: Firefox
- Browser Version: 141.0
- Bundler: Vite
- Bundler Version: 6.3.5
Additional context
No response