Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nstepien opened this issue Jan 8, 2025 · 0 comments
Open

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

nstepien opened this issue Jan 8, 2025 · 0 comments
Labels
types Changes to the typescript types

Comments

@nstepien
Copy link
Contributor

nstepien commented Jan 8, 2025

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: #3029

@schiller-manuel schiller-manuel added the types Changes to the typescript types label Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
types Changes to the typescript types
Projects
None yet
Development

No branches or pull requests

2 participants