Skip to content

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

Closed
@micah-redwood

Description

@micah-redwood

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

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