Skip to content

Commit e6a5372

Browse files
committed
chore: format
1 parent f3c6421 commit e6a5372

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

packages/router/utils.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,13 @@ export interface DataRouteObject extends RouteObject {
164164
// Recursive helper for finding path parameters in the absence of wildcards
165165
type _PathParam<Path extends string> =
166166
// split path into individual path segments
167-
Path extends `${infer L}/${infer R}` ? _PathParam<L> | _PathParam<R> :
168-
// find params after `:`
169-
Path extends `${string}:${infer Param}` ? Param :
170-
// otherwise, there aren't any params present
171-
never
167+
Path extends `${infer L}/${infer R}`
168+
? _PathParam<L> | _PathParam<R>
169+
: // find params after `:`
170+
Path extends `${string}:${infer Param}`
171+
? Param
172+
: // otherwise, there aren't any params present
173+
never;
172174

173175
/**
174176
* Examples:
@@ -181,19 +183,20 @@ type _PathParam<Path extends string> =
181183
*/
182184
type PathParam<Path extends string> =
183185
// check if path is just a wildcard
184-
Path extends "*" ? "*" :
185-
// look for wildcard at the end of the path
186-
Path extends `${infer Rest}/*` ? "*" | _PathParam<Rest> :
187-
// look for params in the absence of wildcards
188-
_PathParam<Path>
186+
Path extends "*"
187+
? "*"
188+
: // look for wildcard at the end of the path
189+
Path extends `${infer Rest}/*`
190+
? "*" | _PathParam<Rest>
191+
: // look for params in the absence of wildcards
192+
_PathParam<Path>;
189193

190194
// Attempt to parse the given string segment. If it fails, then just return the
191195
// plain string type as a default fallback. Otherwise return the union of the
192196
// parsed string literals that were referenced as dynamic segments in the route.
193197
export type ParamParseKey<Segment extends string> =
194198
// if could not find path params, fallback to `string`
195-
[PathParam<Segment>] extends [never] ? string :
196-
PathParam<Segment>
199+
[PathParam<Segment>] extends [never] ? string : PathParam<Segment>;
197200

198201
/**
199202
* The parameters that were parsed from the URL path.

0 commit comments

Comments
 (0)