remix-run / react-router

Declarative routing for React
https://reactrouter.com
MIT License
53.25k stars 10.32k forks source link

[Bug]: Framework codegen produces invalid types when using absolute child route paths #12359

Open fenok opened 2 days ago

fenok commented 2 days ago

What version of React Router are you using?

7.0.1

Steps to Reproduce

In an app that uses React Router as a framework (I used create-react-router@latest), define routes like this:

export default [route('/:a', 'routes/page.tsx', [route('/:a/:b', 'routes/subpage.tsx')])] satisfies RouteConfig;

In real life, paths are built by a separate tool, and this approach is more convenient.

Expected Behavior

import type { Route } from "./+types/subpage";

// Should be { a: string; b: string }
type Params = Route.MetaArgs['params'];

Actual Behavior

import type { Route } from "./+types/subpage";

// Actually it's { a: [ string, string ]; b: string }
type Params = Route.MetaArgs['params'];