You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Generated type FileRoutesByFullPath doesn't match runtime type #3780
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.
import{useRouter,typeRegisteredRouter}from"@tanstack/react-router";typeFileRoutesByFullPath=RegisteredRouter["routesByPath"];typeRouteFullPathWithSlash=keyofFileRoutesByFullPath;typeTrimSlash<Textendsstring>=Textends `${infer P}/` ? P : T;/** * Type-safe wrapper around `routesByPath` that handles the mismatch between * the generated types (which include trailing slashes for index routes) and * the runtime object (which trims them). * * @see https://github.com/TanStack/router/issues/3780 */functionuseRoutePath<TextendsRouteFullPathWithSlash>(path: T): TrimSlash<T>{const{ routesByPath }=useRouter();// The generated FileRoutesByFullPath type includes trailing slashes for index// routes, but routesByPath trims them at runtime — so we trim before lookup.consttrimmed=path.replace(/\/$/,"")asT;returnroutesByPath[trimmed].fullPathasTrimSlash<T>;}export{useRoutePath};
Activity
schiller-manuel commentedon Mar 15, 2025
same as #3005 ?
am-a commentedon Mar 15, 2025
Not quite the same, almost the inverse. Probably fixed in the same area though.
codeart1st commentedon Oct 13, 2025
This issue seems still relevant
SemStassen commentedon Mar 2, 2026
Still relevant. This is my current workaround.
schiller-manuel commentedon Mar 7, 2026
closing this as neither those types nor the router properties are public API.