Fuzzy match for deep links with missing parent route not allowed by types
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 15.1k
- Forks
- 1.9k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 143
Description
Which project does this relate to?
Router
Describe the bug
When trying to fuzzily match deep paths at a level that does not have a route, the types do not allow it.
// this should be allowed when on the `/very/deep/path` route
useMatchRoute().matchRoute({ to: '/very', fuzzy: true });
Your Example Website or App
Steps to Reproduce the Bug or Issue
- Create deep routes without a parent route
- Try to match a common parent route of those routes
The types prohibit this match: to is flagged as invalid and the returned type is false when.
The runtime allows this match: no runtime error, and the returned value is an object like { '**': 'deep/path' }
Expected behavior
Types should not prohibit this.
Screenshots or Videos
No response
Platform
- OS: Win11
- Browser: Chrome
- Version: 131.0.6778.140
Additional context
Is this because there is no "route" to match?
Either way, the types do not match the runtime behavior.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the type mismatch in the linked StackBlitz using src/routes/very/deep/path.tsx and src/routes/__root.tsx. Start from the useMatchRoute().matchRoute call and compare the declared route type with the runtime result for the missing parent path. Done means the deep-link example type-checks and preserves the runtime match object.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100