[Typesafe routing] Uncatched typescript error
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
I expect TS to catch an invalid navigation construct. When doing some dynamic routing, if I inject a union type as to param, in certain situation TS seems to ignore invalid routes.
In the example, you'll see that using absolute path raise the error, while relative one is silently ignored.
Your Example Website or App
https://stackblitz.com/edit/tanstack-router-vh8dm4rb?file=src%2Froutes%2Findex.tsx
Steps to Reproduce the Bug or Issue
- Open the repro
- See the TS error in action
Expected behavior
Ideally, the TS error should be consistent while using absolute/relative routing.
Screenshots or Videos
No response
Platform
- Router / Start Version: [e.g. 1.121.0]
- OS: [e.g. macOS, Windows, Linux]
- Browser: [e.g. Chrome, Safari, Firefox]
- Browser Version: [e.g. 91.1]
- Bundler: [e.g. vite]
- Bundler Version: [e.g. 7.0.0]
Additional context
No response
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
Start with the StackBlitz reproduction at src/routes/index.tsx and compare the absolute and relative navigation cases using a union type for the to parameter. Trace the router's TypeScript route validation to determine why the relative case accepts an invalid route; done means both forms report the expected type error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100