Description
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
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'.