File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -465,15 +465,19 @@ function matchRouteBranch<
465
465
* @see https://reactrouter.com/docs/en/v6/utils/generate-path
466
466
*/
467
467
export function generatePath < Path extends string > ( path : Path , params : {
468
- [ key in PathParams < Path > | ( string & { } ) ] : string
468
+ [ key in PathParams < Path > ] : string
469
469
} = { } as any ) : string {
470
470
return path
471
- . replace ( / : ( \w + ) / g, ( _ , key ) => {
471
+ . replace ( / : ( \w + ) / g, ( _ , key : PathParams < Path > ) => {
472
472
invariant ( params [ key ] != null , `Missing ":${ key } " param` ) ;
473
473
return params [ key ] ! ;
474
474
} )
475
475
. replace ( / \/ * \* $ / , ( _ ) =>
476
- params [ "*" ] == null ? "" : params [ "*" ] . replace ( / ^ \/ * / , "/" )
476
+ {
477
+ const star = "*" as PathParams < Path >
478
+
479
+ return params [ star ] == null ? "" : params [ star ] . replace ( / ^ \/ * / , "/" )
480
+ }
477
481
) ;
478
482
}
479
483
You can’t perform that action at this time.
0 commit comments