Open
Description
Which project does this relate to?
Router
Describe the bug
Problem
router.routesByPath
is defined as RoutesByPath<TRouteTree>
which includes trailing '/' for index routes. However this does not match the runtime type which removes trailing slashes.
Description
Given the following structure:
foo/
└── bar/
├── index.tsx
├── route.tsx
└── __root.tsx
generates:
export interface FileRoutesByFullPath {
'/bar': typeof fooBarRouteRouteWithChildren
'/bar/': typeof fooBarIndexRoute
}
but in:
if (!childRoute.isRoot && childRoute.path) {
const trimmedFullPath = trimPathRight(childRoute.fullPath)
if (
!(this.routesByPath as any)[trimmedFullPath] ||
childRoute.fullPath.endsWith('/')
) {
;(this.routesByPath as any)[trimmedFullPath] = childRoute
}
}
we can see that the trimmed path is the key that is used for the object at runtime.
Your Example Website or App
https://stackblitz.com/edit/tanstack-router-nychtyxe
Steps to Reproduce the Bug or Issue
- Create a router project with an index route matching above structure
- Observe that Types does not match runtime types
Expected behavior
The typing for the property should match the runtime type i.e. without slashes
Screenshots or Videos
Platform
All
Additional context
The included link goes to a StackBlitz where you can quickly see the problem in action by comparing the interface and the actual runtime types.
Metadata
Metadata
Assignees
Labels
No labels