Skip to content

Type Guards: isRoute()

Call Signature

ts
function isRoute(route): route is RouterRoute<Readonly<{ hash: string; href: Url; id: string; matched: CreatedRouteOptions; matches: CreatedRouteOptions[]; name: string; params: (key: string) => any; query: URLSearchParams; state: ExtractRouteStateParamsAsOptional<Record<string, Param>> }>>

A type guard for determining if a value is a valid RouterRoute.

Parameters

ParameterTypeDescription
routeunknownThe value to check.

Returns

route is RouterRoute<Readonly<{ hash: string; href: Url; id: string; matched: CreatedRouteOptions; matches: CreatedRouteOptions[]; name: string; params: (key: string) => any; query: URLSearchParams; state: ExtractRouteStateParamsAsOptional<Record<string, Param>> }>>

true if the value is a valid RouterRoute, otherwise false.

Call Signature

ts
function isRoute<TRoute, TRouteName>(
   route, 
   routeName, 
   options): route is TRoute & { name: TRouteName }

A type guard for determining if a value is a valid RouterRoute with an exact match.

Type Parameters

Type Parameter
TRoute extends RouterRoute<Readonly<{ hash: string; href: Url; id: string; matched: CreatedRouteOptions; matches: CreatedRouteOptions[]; name: string; params: {}; query: URLSearchParams; state: ExtractRouteStateParamsAsOptional<Record<string, Param>>; }>>
TRouteName extends string

Parameters

ParameterTypeDescription
routeTRouteThe value to check.
routeNameTRouteNameThe expected route name.
optionsIsRouteOptions & object-

Returns

route is TRoute & { name: TRouteName }

true if the value is a valid RouterRoute with an exact match, otherwise false.

Call Signature

ts
function isRoute<TRoute, TRouteName>(
   route, 
   routeName, 
   options?): route is RouteWithMatch<TRoute, TRouteName>

A type guard for determining if a value is a valid RouterRoute with a partial match.

Type Parameters

Type Parameter
TRoute extends RouterRoute<Readonly<{ hash: string; href: Url; id: string; matched: CreatedRouteOptions; matches: CreatedRouteOptions[]; name: string; params: {}; query: URLSearchParams; state: ExtractRouteStateParamsAsOptional<Record<string, Param>>; }>>
TRouteName extends string

Parameters

ParameterTypeDescription
routeTRouteThe value to check.
routeNameTRouteNameThe expected route name.
options?IsRouteOptions-

Returns

route is RouteWithMatch<TRoute, TRouteName>

true if the value is a valid RouterRoute with a partial match, otherwise false.

Call Signature

ts
function isRoute<TRouteName>(
   route, 
   routeName, 
   options): route is RouterRoute<Readonly<{ hash: string; href: Url; id: any; matched: any; matches: any; name: any; params: { (key: string): any; (key: number): any; (key: symbol): any }; query: URLSearchParams; state: ExtractRouteStateParamsAsOptional<any> }>> & { name: TRouteName }

A type guard for determining if a value is a valid RegisteredRouterRoute with an exact match.

Type Parameters

Type Parameter
TRouteName extends string

Parameters

ParameterTypeDescription
routeunknownThe value to check.
routeNameTRouteNameThe expected route name.
optionsIsRouteOptions & object-

Returns

route is RouterRoute<Readonly<{ hash: string; href: Url; id: any; matched: any; matches: any; name: any; params: { (key: string): any; (key: number): any; (key: symbol): any }; query: URLSearchParams; state: ExtractRouteStateParamsAsOptional<any> }>> & { name: TRouteName }

true if the value is a valid RegisteredRouterRoute with an exact match, otherwise false.

Call Signature

ts
function isRoute<TRouteName>(
   route, 
   routeName, 
   options?): route is TRouteName extends any ? RouterRoute<Readonly<{ hash: string; href: Url; id: any; matched: any; matches: any; name: any; params: { (key: string): any; (key: number): any; (key: symbol): any }; query: URLSearchParams; state: ExtractRouteStateParamsAsOptional<any> }>> : never

A type guard for determining if a value is a valid RegisteredRouterRoute with a partial match.

Type Parameters

Type Parameter
TRouteName extends string

Parameters

ParameterTypeDescription
routeunknownThe value to check.
routeNameTRouteNameThe expected route name.
options?IsRouteOptions-

Returns

route is TRouteName extends any ? RouterRoute<Readonly<{ hash: string; href: Url; id: any; matched: any; matches: any; name: any; params: { (key: string): any; (key: number): any; (key: symbol): any }; query: URLSearchParams; state: ExtractRouteStateParamsAsOptional<any> }>> : never

true if the value is a valid RegisteredRouterRoute with a partial match, otherwise false.

Call Signature

ts
function isRoute(
   route, 
   routeName?, 
   options?): boolean

A type guard for determining if a value is a valid RouterRoute.

Parameters

ParameterTypeDescription
routeunknownThe value to check.
routeName?stringThe expected route name.
options?IsRouteOptions-

Returns

boolean

true if the value is a valid RouterRoute, otherwise false.