Skip to content

type error when passing number to Link.params #5559

@scarf005

Description

@scarf005

Which project does this relate to?

Router

Describe the bug

despite the docs:

<Link
to="/posts/{-$category}"
params={{ category: 123 }} // ✅ Valid - number (auto-stringified)
>
Category 123
</Link>

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    typesChanges to the typescript types

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions