TanStack / TanStack/router

A `from` union should result in a intersection of relative `to` paths

Open
#3,011 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

types
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 from is a union of different paths, to allows a union of relative paths for from instead of an intersection, resulting in invalid links.

Your Example Website or App

https://stackblitz.com/edit/github-dj5qylfv?file=src%2FPage.tsx,src%2Froutes%2F__root.tsx,src%2Froutes%2Fposts%2Fpost%2F%24postId.tsx,src%2Froutes%2Fusers%2Fuser%2F%24userId.tsx

Steps to Reproduce the Bug or Issue
  1. Use a from that is an union of different valid paths
  2. Write a relative to
Expected behavior

to should only allow relative paths that are valid for all from paths.

Screenshots or Videos

No response

Platform
  • OS: Windows
  • Browser: Chrome
  • Version: 131.0.6778.140
Additional context

I wonder if this can be done in TS 🤔

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked StackBlitz reproduction and the referenced files: src/Page.tsx, src/routes/__root.tsx, src/routes/posts/post/$postId.tsx, and src/routes/users/user/$userId.tsx. Reproduce a relative to with a union-valued from, then trace the router's TypeScript path types. Done means invalid relative paths are rejected when they are not valid for every from path.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.