@@ -22,11 +22,11 @@ import type {
2222 FullSearchSchema ,
2323 FullSearchSchemaInput ,
2424 ParentPath ,
25- RootPath ,
2625 RouteByPath ,
2726 RouteByToPath ,
2827 RoutePaths ,
2928 RouteToPath ,
29+ ToPath ,
3030 TrailingSlashOptionByRouter ,
3131} from './routeInfo'
3232import type {
@@ -79,26 +79,27 @@ export type RemoveLeadingSlashes<T> = T extends `/${string}`
7979export type FindDescendantPaths <
8080 TRouter extends AnyRouter ,
8181 TPrefix extends string ,
82- TCleanedPrefix extends string = RemoveTrailingSlashes < TPrefix > ,
83- > = ( TPrefix | `${TCleanedPrefix } /${string } `) & RouteToPath < TRouter >
82+ > = `${TPrefix } /${string } ` & RouteToPath < TRouter >
8483
8584export type SearchPaths <
8685 TRouter extends AnyRouter ,
8786 TPrefix extends string ,
8887 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
9693
9794export type SearchRelativePathAutoComplete <
9895 TRouter extends AnyRouter ,
9996 TTo extends string ,
10097 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 > > } `
102103
103104export type RelativeToParentPathAutoComplete <
104105 TRouter extends AnyRouter ,
@@ -110,7 +111,10 @@ export type RelativeToParentPathAutoComplete<
110111 | ( TTo extends `${string } ..` | `${string } ../`
111112 ? TResolvedPath extends '/' | ''
112113 ? never
113- : FindDescendantPaths < TRouter , TResolvedPath > extends never
114+ : FindDescendantPaths <
115+ TRouter ,
116+ RemoveTrailingSlashes < TResolvedPath >
117+ > extends never
114118 ? never
115119 : `${TTo } /${ParentPath < TrailingSlashOptionByRouter < TRouter > > } `
116120 : never )
@@ -132,9 +136,7 @@ export type AbsolutePathAutoComplete<
132136 ? CurrentPath < TrailingSlashOptionByRouter < TRouter > >
133137 : TFrom extends `/`
134138 ? never
135- : FindDescendantPaths < TRouter , TFrom > extends never
136- ? never
137- : CurrentPath < TrailingSlashOptionByRouter < TRouter > > )
139+ : CurrentPath < TrailingSlashOptionByRouter < TRouter > > )
138140 | ( string extends TFrom
139141 ? ParentPath < TrailingSlashOptionByRouter < TRouter > >
140142 : TFrom extends `/`
@@ -145,9 +147,7 @@ export type AbsolutePathAutoComplete<
145147 ? never
146148 : string extends TFrom
147149 ? never
148- : RemoveLeadingSlashes <
149- SearchPaths < TRouter , RemoveTrailingSlashes < TFrom > >
150- > )
150+ : SearchPaths < TRouter , RemoveTrailingSlashes < TFrom > > )
151151
152152export type RelativeToPathAutoComplete <
153153 TRouter extends AnyRouter ,
0 commit comments