Skip to content

Commit f6da1b8

Browse files
committed
docs(router): remove internal types from type description for generatePath
1 parent 980c11e commit f6da1b8

File tree

1 file changed

+0
-25
lines changed

1 file changed

+0
-25
lines changed

docs/utils/generate-path.md

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,6 @@ title: generatePath
88
<summary>Type declaration</summary>
99

1010
```tsx
11-
// Recursive helper for finding path parameters in the absence of wildcards
12-
type _PathParam<Path extends string> =
13-
// split path into individual path segments
14-
Path extends `${infer L}/${infer R}` ? _PathParam<L> | _PathParam<R> :
15-
// find params after `:`
16-
Path extends `${string}:${infer Param}` ? Param :
17-
// otherwise, there aren't any params present
18-
never
19-
20-
/**
21-
* Examples:
22-
* "/a/b/*" -> "/*"
23-
* ":a" -> "a"
24-
* "/a/:b" -> "b"
25-
* "/:a/:b" -> "a" | "b"
26-
*/
27-
type PathParam<Path extends string> =
28-
// check if path is just a wildcard
29-
Path extends "*" ? "*" :
30-
// look for wildcard at the end of the path
31-
Path extends `${infer Rest}/*` ? "*" | _PathParam<Rest> :
32-
// look for params in the absence of wildcards
33-
_PathParam<Path>
34-
35-
3611
declare function generatePath<Path extends string>(
3712
path: Path,
3813
params?: {

0 commit comments

Comments
 (0)