@@ -22,11 +22,11 @@ import type {
22
22
FullSearchSchema ,
23
23
FullSearchSchemaInput ,
24
24
ParentPath ,
25
- RootPath ,
26
25
RouteByPath ,
27
26
RouteByToPath ,
28
27
RoutePaths ,
29
28
RouteToPath ,
29
+ ToPath ,
30
30
TrailingSlashOptionByRouter ,
31
31
} from './routeInfo'
32
32
import type {
@@ -79,26 +79,27 @@ export type RemoveLeadingSlashes<T> = T extends `/${string}`
79
79
export type FindDescendantPaths <
80
80
TRouter extends AnyRouter ,
81
81
TPrefix extends string ,
82
- TCleanedPrefix extends string = RemoveTrailingSlashes < TPrefix > ,
83
- > = ( TPrefix | `${TCleanedPrefix } /${string } `) & RouteToPath < TRouter >
82
+ > = `${TPrefix } /${string } ` & RouteToPath < TRouter >
84
83
85
84
export type SearchPaths <
86
85
TRouter extends AnyRouter ,
87
86
TPrefix extends string ,
88
87
TPaths = FindDescendantPaths < TRouter , TPrefix > ,
89
- TCleanedPrefix extends string = RemoveTrailingSlashes < TPrefix > ,
90
- TRootPath = RootPath < TrailingSlashOptionByRouter < TRouter > > ,
91
- > = TPaths extends TPrefix
92
- ? TRootPath
93
- : TPaths extends `${TCleanedPrefix } /${infer TRest } `
94
- ? `/${TRest } `
95
- : never
88
+ > = TPaths extends `${TPrefix } /${infer TRest } `
89
+ ? TRest extends ''
90
+ ? never
91
+ : TRest
92
+ : never
96
93
97
94
export type SearchRelativePathAutoComplete <
98
95
TRouter extends AnyRouter ,
99
96
TTo extends string ,
100
97
TSearchPath extends string ,
101
- > = `${TTo } ${SearchPaths < TRouter , TSearchPath > } `
98
+ > =
99
+ | ( TSearchPath & RouteToPath < TRouter > extends never
100
+ ? never
101
+ : ToPath < TrailingSlashOptionByRouter < TRouter > , TTo > )
102
+ | `${TTo } /${SearchPaths < TRouter , RemoveTrailingSlashes < TSearchPath > > } `
102
103
103
104
export type RelativeToParentPathAutoComplete <
104
105
TRouter extends AnyRouter ,
@@ -110,7 +111,10 @@ export type RelativeToParentPathAutoComplete<
110
111
| ( TTo extends `${string } ..` | `${string } ../`
111
112
? TResolvedPath extends '/' | ''
112
113
? never
113
- : FindDescendantPaths < TRouter , TResolvedPath > extends never
114
+ : FindDescendantPaths <
115
+ TRouter ,
116
+ RemoveTrailingSlashes < TResolvedPath >
117
+ > extends never
114
118
? never
115
119
: `${TTo } /${ParentPath < TrailingSlashOptionByRouter < TRouter > > } `
116
120
: never )
@@ -132,9 +136,7 @@ export type AbsolutePathAutoComplete<
132
136
? CurrentPath < TrailingSlashOptionByRouter < TRouter > >
133
137
: TFrom extends `/`
134
138
? never
135
- : FindDescendantPaths < TRouter , TFrom > extends never
136
- ? never
137
- : CurrentPath < TrailingSlashOptionByRouter < TRouter > > )
139
+ : CurrentPath < TrailingSlashOptionByRouter < TRouter > > )
138
140
| ( string extends TFrom
139
141
? ParentPath < TrailingSlashOptionByRouter < TRouter > >
140
142
: TFrom extends `/`
@@ -145,9 +147,7 @@ export type AbsolutePathAutoComplete<
145
147
? never
146
148
: string extends TFrom
147
149
? never
148
- : RemoveLeadingSlashes <
149
- SearchPaths < TRouter , RemoveTrailingSlashes < TFrom > >
150
- > )
150
+ : SearchPaths < TRouter , RemoveTrailingSlashes < TFrom > > )
151
151
152
152
export type RelativeToPathAutoComplete <
153
153
TRouter extends AnyRouter ,
0 commit comments