Skip to content
Source
Sign inSign up
TanStack/router

`navigate()`'s `to` prop should not widen value type #3128

Send to my agent
Opennstepien(GitHub profile, opens in a new tab) opened this issue 0 comments

Which project does this relate to?

Router

Describe the bug

When using string templates + string unions, the to prop of navigate() will widen the type of the value to string instead of using the narrowed type.

Your Example Website or App

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

Steps to Reproduce the Bug or Issue

  1. Open example
  2. Edit file if type errors don't show up
  3. Notice how navigate() types can catch issues with from with or without as const, and issues with to with as const.
  4. Notice how navigate() types fail to catch issues with to without as const

Expected behavior

navigate() should work like linkOptions()

Screenshots or Videos

No response

Platform

  • OS: Windows
  • Browser: Chrome
  • Version: 131.0.6778.265

Additional context

Previously related issue: https://github.com/TanStack/router/issues/3029

Sign in to join this conversation.