TanStack / TanStack/router

type error when passing number to `Link.params`

Open
#5,559 0 comments 2 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

despite the docs: https://github.com/TanStack/router/blob/410fdf808d959de0efb92a9d1339048a7cd053f1/docs/router/framework/react/guide/path-params.md?plain=1#L409-L414

putting numbers in params on Link component gives type error

Your Example Website or App

https://stackblitz.com/edit/github-ynvn4fan?file=src%2Froutes%2F__root.tsx

Steps to Reproduce the Bug or Issue
  1. create any route with params e.g $foo.bar.tsx
  2. <Link to="/$foo/bar" params={{ foo: 3 }}>
  3. get type error that you cannot assign number to string
Expected behavior

type works like the docs
the numbers do get auto-stringified, but the type error makes everything cumbersome (have to wrap in String)

Screenshots or Videos
Image
Platform
  • Router / Start Version: 1.133.20
  • OS: macOS
  • Browser: Firefox
  • Browser Version: 145.0b3
  • Bundler: vite
  • Bundler Version: 7.1.7
Additional context

for some reason this error isn't reproducible on tanstack/router repo.

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 React path-params documentation at the referenced lines, using a route such as $foo.bar.tsx and Link with params={{ foo: 3 }}. Compare its generated types with the TanStack Router repository, where the issue says the problem is not reproducible; done means numeric Link.params values type-check while retaining the documented auto-stringification behavior.

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.