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

trailingSlash: "always" breaks <Link /> and navigate() types in v1.91.0 onwards #3052

Open
micah-redwood opened this issue Dec 20, 2024 · 0 comments · May be fixed by #3084
Open

trailingSlash: "always" breaks <Link /> and navigate() types in v1.91.0 onwards #3052

micah-redwood opened this issue Dec 20, 2024 · 0 comments · May be fixed by #3084
Labels
types Changes to the typescript types

Comments

@micah-redwood
Copy link

Which project does this relate to?

Router

Describe the bug

When I updated @tanstack/react-router and @tanstack/start from 1.90 to 1.91 all of my <Link />, navigate() and linkOptions types started breaking due to having trailingSlash: "always" in my router config.

I've replicated in a very simple repo w/ just two routes. Before the upgrade:
Image

After the upgrade:
npm i @tanstack/[email protected] @tanstack/[email protected]
Image
Image

It appears that the behavior of enforcing trailing slashes in Typescript no longer works (runtime behavior is unchanged)

Oddly enough, even if I link to: "/page-1" without the trailing slash, it's still broken and asks for me to specify a search parameter even though there's no search param associated with this route:
Image

The moment I remove trailingSlash: "always" from my router config, the type errors go away.

This bug appears to be introduced in release 1.91.0 and persists for all subsequent versions that I've tried.

Appreciate your help, thanks!

Your Example Website or App

https://github.com/micah-redwood/tanstack-start-trailingslash-bug

Steps to Reproduce the Bug or Issue

  1. Clone down this repo
  2. See type error in file routes/index.tsx
  3. Revert dependencies to 1.90 for the error to go away:
    npm i @tanstack/[email protected] @tanstack/[email protected]

This repo is just a very simple one created by following the docs. I added one extra route: /page-1 and added trailingSlash: "always" in the router config and simplified the homepage to just include a link to this page-1 route

Expected behavior

There should be no type errors for this simple use case.

Screenshots or Videos

No response

Platform

  • OS: MacOS Sonoma (VSCode)

Additional context

No response

@SeanCassiere SeanCassiere added the types Changes to the typescript types label Dec 22, 2024
@chorobin chorobin linked a pull request Dec 27, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants