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

to allows the string type #2623

Open
nstepien opened this issue Oct 22, 2024 · 2 comments
Open

to allows the string type #2623

nstepien opened this issue Oct 22, 2024 · 2 comments

Comments

@nstepien
Copy link

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.

@schiller-manuel schiller-manuel added the enhancement New feature or request label Oct 22, 2024
@schiller-manuel
Copy link
Contributor

schiller-manuel commented Oct 22, 2024

we have been thinking about this. thanks for opening this issue to remind us :)

@swbtrifork
Copy link

My workaround for now seems to be to narrow the type manually by using as const satisfies LinkProps["to"];, but this was also an issue for me, especially in shared components.

@SeanCassiere SeanCassiere removed the enhancement New feature or request label Oct 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants