File tree 2 files changed +14
-0
lines changed
packages/react-router-dev/typegen
2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @react-router/dev " : patch
3
+ ---
4
+
5
+ Fix duplicated entries in typegen for layout routes and their corresponding index route
Original file line number Diff line number Diff line change @@ -103,6 +103,12 @@ function register(ctx: Context) {
103
103
104
104
const { t } = Babel ;
105
105
106
+ const indexPaths = new Set (
107
+ Object . values ( ctx . config . routes )
108
+ . filter ( ( route ) => route . index )
109
+ . map ( ( route ) => route . path )
110
+ ) ;
111
+
106
112
const typeParams = t . tsTypeAliasDeclaration (
107
113
t . identifier ( "Params" ) ,
108
114
null ,
@@ -112,6 +118,9 @@ function register(ctx: Context) {
112
118
// filter out pathless (layout) routes
113
119
if ( route . id !== "root" && ! route . path ) return undefined ;
114
120
121
+ // filter out layout routes that have a corresponding index
122
+ if ( ! route . index && indexPaths . has ( route . path ) ) return undefined ;
123
+
115
124
const lineage = Route . lineage ( ctx . config . routes , route ) ;
116
125
const fullpath = Route . fullpath ( lineage ) ;
117
126
const params = Params . parse ( fullpath ) ;
You can’t perform that action at this time.
0 commit comments