router icon indicating copy to clipboard operation
router copied to clipboard

router.matchRoute doesn't resolve TS type with pathless (layout) routes

Open vladrasenko opened this issue 1 month ago • 1 comments

Which project does this relate to?

Router

Describe the bug

When trying to use the router.matchRoute function with a path that is contained within a pathless route, the resulting match result is typed to false. Running the function returns the correct value. It's only TS issue.

Your Example Website or App

https://stackblitz.com/edit/github-trezcbpr?file=src%2Fmain.tsx

Steps to Reproduce the Bug or Issue

  1. Create route routes/_pathless/route.tsx
  2. Create nested route routes/_pathless/nested/$id.tsx
  3. Call router.matchRoute (use global router instance) with "/nested/$id.tsx"
  // match has type 'false'
  const match = router.matchRoute({
    to: '/nested/$id',
    params: {
      id: 'someId',
    },
  });

  return match && match.id; // Property 'id' does not exist on type 'never'.(2339)

Expected behavior

return type is false | ResolveParams<"/_pathless/nested/$id"> instead of false

Screenshots or Videos

Image Image Image

Platform

  • Router Version: 1.139.12
  • OS: macOS
  • Browser: Chrome
  • Browser Version: 142.0.7444.176
  • Bundler: vite
  • Bundler Version: 7.1.7

Additional context

Maybe the same reason as at https://github.com/TanStack/router/issues/1680

vladrasenko avatar Dec 02 '25 15:12 vladrasenko

Hey! Is this issue still available? I’d love to work on it

devel-maverick avatar Dec 03 '25 16:12 devel-maverick