-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Closed
Labels
Description
I'm using React Router as a...
framework
Reproduction
Go to https://stackblitz.com/edit/github-8rw532i2?file=package.json and run npm run typecheck in the terminal.
System Info
System:
OS: Linux 5.0 undefined
CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 0 Bytes / 0 Bytes
Shell: 1.0 - /bin/jsh
Binaries:
Node: 18.20.3 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 10.2.3 - /usr/local/bin/npm
pnpm: 8.15.6 - /usr/local/bin/pnpm
npmPackages:
@react-router/dev: 7.2.0 => 7.2.0
@react-router/fs-routes: 7.2.0 => 7.2.0
@react-router/node: 7.2.0 => 7.2.0
@react-router/serve: 7.2.0 => 7.2.0
react-router: 7.2.0 => 7.2.0
vite: ^6.0.11 => 6.1.0Used Package Manager
npm
Expected Behavior
I would expect it to handle routes like this that opt-out of nested layouts as 7.1.5 does.
Actual Behavior
npm run typecheck will fail with the following:
.react-router/types/+register.ts:11:3 - error TS2300: Duplicate identifier '/admin'.
11 "/admin": {};
~~~~~~~~
.react-router/types/+register.ts:12:3 - error TS2300: Duplicate identifier '/admin'.
12 "/admin": {};
~~~~~~~~
Found 2 errors in the same file, starting at: .react-router/types/+register.ts:11
Run cat .react-router/types/+register.ts and see the duplicate entries for /admin in the Params type:
import "react-router";
declare module "react-router" {
interface Register {
params: Params;
}
}
type Params = {
"/": {};
"/admin": {};
"/admin": {};
"/admin/users": {};
"/home": {};
};
This seems to happen when you have a layout route and an index route for the same path that opts out of said layout route. In this example:
<Routes>
<Route file="root.tsx">
{/* admin index route, opting out of admin layout */}
<Route path="admin" index file="routes/admin_._index.tsx" />
{/* admin layout route */}
<Route path="admin" file="routes/admin.tsx">
<Route path="users" file="routes/admin.users.tsx" />
</Route>
<Route path="home" file="routes/home.tsx" />
</Route>
</Routes>jesperronn