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

href utility missing valid routes with flatRoutes #13279

Open
kevinbailey25 opened this issue Mar 20, 2025 · 1 comment
Open

href utility missing valid routes with flatRoutes #13279

kevinbailey25 opened this issue Mar 20, 2025 · 1 comment
Labels

Comments

@kevinbailey25
Copy link

kevinbailey25 commented Mar 20, 2025

I'm using React Router as a...

framework

Reproduction

The href utility is missing some valid routes. I have 2 fairly large projects with this problem. With version 7.2.0 I added href utility everywhere which has been helpful. Although when I upgraded to 7.3.0 or 7.4.0 some of those routes (which still work perfectly fine), aren't available in the href utility.

I've created this very small reproduction using flatRoutes with 3 route files.

routes/roles.tsx
routes/users.roles._index.tsx
routes/users.tsx

I should have these routes available:

/roles
/users/roles
/users

But for whatever reason, the /roles route is not available in the href utility. Now I know I could just rename some of these but I believe this should be valid. My 2 other projects have much more complicated routes with many more nested layouts and url params and such. But this is the bare minimum I can create to repo the issue to help narrow it down.

Here's the repo: https://github.com/kevinbailey25/test-flat-routes

Just run npm run typecheck and you'll see the TS error

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12700K
    Memory: 16.87 GB / 31.75 GB
  Binaries:
    Node: 22.13.0 - C:\Program Files\nodejs\node.EXE
    npm: 11.2.0 - C:\Program Files\nodejs\npm.CMD
    bun: 1.2.2 - ~\.bun\bin\bun.EXE
  Browsers:
    Edge: Chromium (131.0.2903.86)
    Internet Explorer: 11.0.22621.3527
  npmPackages:
    @react-router/dev: ^7.4.0 => 7.4.0
    @react-router/fs-routes: ^7.4.0 => 7.4.0
    @react-router/node: ^7.4.0 => 7.4.0
    @react-router/serve: ^7.4.0 => 7.4.0
    react-router: ^7.4.0 => 7.4.0
    vite: ^5.4.11 => 5.4.14

Used Package Manager

npm

Expected Behavior

There should be no TS errors.

Actual Behavior

TS Error: Argument of type '"/roles"' is not assignable to parameter of type 'keyof Params'.

@kevinbailey25
Copy link
Author

Also confirmed that this issue is happening on Mac.

  System:
    OS: macOS 14.5
    CPU: (8) arm64 Apple M2
    Memory: 95.81 MB / 8.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.13.0 - ~/.nvm/versions/node/v22.13.0/bin/node
    npm: 11.1.0 - ~/.nvm/versions/node/v22.13.0/bin/npm
    bun: 1.1.42 - ~/.bun/bin/bun
  Browsers:
    Chrome: 134.0.6998.118
    Safari: 17.5
  npmPackages:
    @react-router/dev: ^7.4.0 => 7.4.0
    @react-router/fs-routes: ^7.4.0 => 7.4.0
    @react-router/node: ^7.4.0 => 7.4.0
    @react-router/serve: ^7.4.0 => 7.4.0
    react-router: ^7.4.0 => 7.4.0
    vite: ^5.4.11 => 5.4.14

@kevinbailey25 kevinbailey25 changed the title href utility missing valid routes href utility missing valid routes with flat routes Mar 21, 2025
@kevinbailey25 kevinbailey25 changed the title href utility missing valid routes with flat routes href utility missing valid routes with flatRoutes Mar 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant