TanStack / TanStack/router

`to` and `from` allow the `string` type

Open
#2,623 5 comments 2 reactions 0 assignees View on GitHub

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

As the title says, to accepts the string type, meaning that these examples will be "valid":

router.navigate({ to: `/posts?filter=${filter}` });

<Link to={`/posts?filter=${filter}`} />
Your Example Website or App

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

Steps to Reproduce the Bug or Issue
  1. Pass a value of type string to to
Expected behavior

The string type should not be accepted by to's type

Screenshots or Videos

No response

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

I don't know if this is intentional, but it's making migrating away from another router more difficult as we can't automatically trust links/navigations.

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 Router type definitions for the to and from options, using the linked StackBlitz example to reproduce the accepted string type. The issue is done when plain string values are rejected for both navigation and Link usage while valid route values remain accepted.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.