@@ -145,16 +145,19 @@ interface DataFunctionArgs<Context> {
145
145
146
146
// TODO: (v7) Change the defaults from any to unknown in and remove Remix wrappers:
147
147
// ActionFunction, ActionFunctionArgs, LoaderFunction, LoaderFunctionArgs
148
+ // Also, make them a type alias instead of an interface
148
149
149
150
/**
150
151
* Arguments passed to loader functions
151
152
*/
152
- export interface LoaderFunctionArgs < C = any > extends DataFunctionArgs < C > { }
153
+ export interface LoaderFunctionArgs < Context = any >
154
+ extends DataFunctionArgs < Context > { }
153
155
154
156
/**
155
157
* Arguments passed to action functions
156
158
*/
157
- export interface ActionFunctionArgs < C = any > extends DataFunctionArgs < C > { }
159
+ export interface ActionFunctionArgs < Context = any >
160
+ extends DataFunctionArgs < Context > { }
158
161
159
162
/**
160
163
* Loaders and actions can return anything except `undefined` (`null` is a
@@ -166,15 +169,19 @@ type DataFunctionValue = Response | NonNullable<unknown> | null;
166
169
/**
167
170
* Route loader function signature
168
171
*/
169
- export interface LoaderFunction < C = any > {
170
- ( args : LoaderFunctionArgs < C > ) : Promise < DataFunctionValue > | DataFunctionValue ;
172
+ export interface LoaderFunction < Context = any > {
173
+ ( args : LoaderFunctionArgs < Context > ) :
174
+ | Promise < DataFunctionValue >
175
+ | DataFunctionValue ;
171
176
}
172
177
173
178
/**
174
179
* Route action function signature
175
180
*/
176
- export interface ActionFunction < C = any > {
177
- ( args : ActionFunctionArgs < C > ) : Promise < DataFunctionValue > | DataFunctionValue ;
181
+ export interface ActionFunction < Context = any > {
182
+ ( args : ActionFunctionArgs < Context > ) :
183
+ | Promise < DataFunctionValue >
184
+ | DataFunctionValue ;
178
185
}
179
186
180
187
/**
@@ -353,10 +360,10 @@ type PathParam<Path extends string> =
353
360
_PathParam < Path > ;
354
361
355
362
// Attempt to parse the given string segment. If it fails, then just return the
356
- // plain string type as a default fallback. Otherwise return the union of the
363
+ // plain string type as a default fallback. Otherwise, return the union of the
357
364
// parsed string literals that were referenced as dynamic segments in the route.
358
365
export type ParamParseKey < Segment extends string > =
359
- // if could not find path params, fallback to `string`
366
+ // if you could not find path params, fallback to `string`
360
367
[ PathParam < Segment > ] extends [ never ] ? string : PathParam < Segment > ;
361
368
362
369
/**
@@ -400,7 +407,7 @@ function isIndexRoute(
400
407
return route . index === true ;
401
408
}
402
409
403
- // Walk the route tree generating unique IDs where necessary so we are working
410
+ // Walk the route tree generating unique IDs where necessary, so we are working
404
411
// solely with AgnosticDataRouteObject's within the Router
405
412
export function convertRoutesToDataRoutes (
406
413
routes : AgnosticRouteObject [ ] ,
@@ -493,12 +500,12 @@ export function matchRoutes<
493
500
return matches ;
494
501
}
495
502
496
- export interface UIMatch < D = unknown , H = unknown > {
503
+ export interface UIMatch < Data = unknown , Handle = unknown > {
497
504
id : string ;
498
505
pathname : string ;
499
506
params : AgnosticRouteMatch [ "params" ] ;
500
- data : D ;
501
- handle : H ;
507
+ data : Data ;
508
+ handle : Handle ;
502
509
}
503
510
504
511
export function convertRouteMatchToUiMatch (
@@ -567,7 +574,7 @@ function flattenRoutes<
567
574
let path = joinPaths ( [ parentPath , meta . relativePath ] ) ;
568
575
let routesMeta = parentsMeta . concat ( meta ) ;
569
576
570
- // Add the children before adding this route to the array so we traverse the
577
+ // Add the children before adding this route to the array, so we traverse the
571
578
// route tree depth-first and child routes appear before their parents in
572
579
// the "flattened" version.
573
580
if ( route . children && route . children . length > 0 ) {
@@ -644,10 +651,10 @@ function explodeOptionalSegments(path: string): string[] {
644
651
let result : string [ ] = [ ] ;
645
652
646
653
// All child paths with the prefix. Do this for all children before the
647
- // optional version for all children so we get consistent ordering where the
654
+ // optional version for all children, so we get consistent ordering where the
648
655
// parent optional aspect is preferred as required. Otherwise, we can get
649
656
// child sections interspersed where deeper optional segments are higher than
650
- // parent optional segments, where for example, /:two would explodes _earlier_
657
+ // parent optional segments, where for example, /:two would explode _earlier_
651
658
// then /:one. By always including the parent as required _for all children_
652
659
// first, we avoid this issue
653
660
result . push (
@@ -656,7 +663,7 @@ function explodeOptionalSegments(path: string): string[] {
656
663
)
657
664
) ;
658
665
659
- // Then if this is an optional value, add all child versions without
666
+ // Then, if this is an optional value, add all child versions without
660
667
if ( isOptional ) {
661
668
result . push ( ...restExploded ) ;
662
669
}
@@ -972,7 +979,7 @@ function compilePath(
972
979
regexpSource += "\\/*$" ;
973
980
} else if ( path !== "" && path !== "/" ) {
974
981
// If our path is non-empty and contains anything beyond an initial slash,
975
- // then we have _some_ form of path in our regex so we should expect to
982
+ // then we have _some_ form of path in our regex, so we should expect to
976
983
// match only if we find the end of this path segment. Look for an optional
977
984
// non-captured trailing slash (to match a portion of the URL) or the end
978
985
// of the path (if we've matched to the end). We used to do this with a
0 commit comments