@@ -13,7 +13,7 @@ import type {
13
13
} from './structuralSharing'
14
14
import type { AnyRoute , ReactNode , StaticDataRouteOption } from './route'
15
15
import type { AnyRouter , RegisteredRouter , RouterState } from './router'
16
- import type { ResolveRelativePath , ToOptions } from './link'
16
+ import type { ResolveRelativePath , ResolveRoute , ToOptions } from './link'
17
17
import type {
18
18
AllContext ,
19
19
AllLoaderData ,
@@ -273,7 +273,7 @@ export type UseMatchRouteOptions<
273
273
TFrom extends RoutePaths < TRouter [ 'routeTree' ] > | string = RoutePaths <
274
274
TRouter [ 'routeTree' ]
275
275
> ,
276
- TTo extends string = '' ,
276
+ TTo extends string | undefined = '' ,
277
277
TMaskFrom extends RoutePaths < TRouter [ 'routeTree' ] > | string = TFrom ,
278
278
TMaskTo extends string = '' ,
279
279
TOptions extends ToOptions <
@@ -297,16 +297,13 @@ export function useMatchRoute<TRouter extends AnyRouter = RegisteredRouter>() {
297
297
298
298
return React . useCallback (
299
299
<
300
- TFrom extends RoutePaths < TRouter [ 'routeTree' ] > | string = string ,
301
- TTo extends string = '' ,
302
- TMaskFrom extends RoutePaths < TRouter [ 'routeTree' ] > | string = TFrom ,
303
- TMaskTo extends string = '' ,
304
- TResolved extends string = ResolveRelativePath < TFrom , NoInfer < TTo > > ,
300
+ const TFrom extends string = string ,
301
+ const TTo extends string | undefined = undefined ,
302
+ const TMaskFrom extends string = TFrom ,
303
+ const TMaskTo extends string = '' ,
305
304
> (
306
305
opts : UseMatchRouteOptions < TRouter , TFrom , TTo , TMaskFrom , TMaskTo > ,
307
- ) :
308
- | false
309
- | RouteByPath < TRouter [ 'routeTree' ] , TResolved > [ 'types' ] [ 'allParams' ] => {
306
+ ) : false | ResolveRoute < TRouter , TFrom , TTo > [ 'types' ] [ 'allParams' ] => {
310
307
const { pending, caseSensitive, fuzzy, includeSearch, ...rest } = opts
311
308
312
309
return router . matchRoute ( rest as any , {
@@ -322,11 +319,9 @@ export function useMatchRoute<TRouter extends AnyRouter = RegisteredRouter>() {
322
319
323
320
export type MakeMatchRouteOptions <
324
321
TRouter extends AnyRouter = RegisteredRouter ,
325
- TFrom extends RoutePaths < TRouter [ 'routeTree' ] > = RoutePaths <
326
- TRouter [ 'routeTree' ]
327
- > ,
328
- TTo extends string = '' ,
329
- TMaskFrom extends RoutePaths < TRouter [ 'routeTree' ] > = TFrom ,
322
+ TFrom extends string = string ,
323
+ TTo extends string | undefined = undefined ,
324
+ TMaskFrom extends string = TFrom ,
330
325
TMaskTo extends string = '' ,
331
326
> = UseMatchRouteOptions < TRouter , TFrom , TTo , TMaskFrom , TMaskTo > & {
332
327
// If a function is passed as a child, it will be given the `isActive` boolean to aid in further styling on the element it returns
@@ -342,15 +337,13 @@ export type MakeMatchRouteOptions<
342
337
343
338
export function MatchRoute <
344
339
TRouter extends AnyRouter = RegisteredRouter ,
345
- TFrom extends RoutePaths < TRouter [ 'routeTree' ] > = RoutePaths <
346
- TRouter [ 'routeTree' ]
347
- > ,
348
- TTo extends string = '' ,
349
- TMaskFrom extends RoutePaths < TRouter [ 'routeTree' ] > = TFrom ,
350
- TMaskTo extends string = '' ,
340
+ const TFrom extends string = string ,
341
+ const TTo extends string | undefined = undefined ,
342
+ const TMaskFrom extends string = TFrom ,
343
+ const TMaskTo extends string = '' ,
351
344
> ( props : MakeMatchRouteOptions < TRouter , TFrom , TTo , TMaskFrom , TMaskTo > ) : any {
352
345
const matchRoute = useMatchRoute ( )
353
- const params = matchRoute ( props as any )
346
+ const params = matchRoute ( props as any ) as boolean
354
347
355
348
if ( typeof props . children === 'function' ) {
356
349
return ( props . children as any ) ( params )
0 commit comments