Skip to content

Commit

Permalink
feat(routes): RouteQuery type
Browse files Browse the repository at this point in the history
Extracts query type from a route object
  • Loading branch information
UberMouse committed Jan 23, 2024
1 parent 2f0553d commit 1468c77
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export {
type LinkProps,
type AnyRoute,
type RouteParams,
type RouteQuery,
type RouteArguments,
type Route,
type RouteMeta,
Expand Down
9 changes: 9 additions & 0 deletions src/routing/createRoute/createRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,15 @@ export type RouteParams<T> = T extends Route<infer TParams, any, any, any>
? TParams
: undefined;

/**
* @public
*
* Extract query type from route
*/
export type RouteQuery<T> = T extends Route<any, infer TQuery, any, any>
? TQuery
: undefined;

/**
* @public
*
Expand Down
1 change: 1 addition & 0 deletions src/routing/createRoute/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export {
type RouteArguments,
type RouteParams,
type RouteMeta,
type RouteQuery,
type ArgumentsForRoute,
type Params,
type Query,
Expand Down
1 change: 1 addition & 0 deletions src/routing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export {
type AnyRoute,
type RouteParams,
type RouteMeta,
type RouteQuery,
type RouteArguments,
type ArgumentsForRoute,
type Params,
Expand Down
9 changes: 6 additions & 3 deletions xstate-tree.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,9 @@ export type RouteMeta<T> = T extends Route<any, any, any, infer TMeta> ? TMeta :
// @public
export type RouteParams<T> = T extends Route<infer TParams, any, any, any> ? TParams : undefined;

// @public
export type RouteQuery<T> = T extends Route<any, infer TQuery, any, any> ? TQuery : undefined;

// @public (undocumented)
export type Routing404Event = {
type: "ROUTING_404";
Expand Down Expand Up @@ -476,9 +479,9 @@ export type XstateTreeMachineStateSchemaV2<TMachine extends AnyStateMachine, TSe

// Warnings were encountered during analysis:
//
// src/routing/createRoute/createRoute.ts:279:19 - (ae-forgotten-export) The symbol "MergeRouteTypes" needs to be exported by the entry point index.d.ts
// src/routing/createRoute/createRoute.ts:279:19 - (ae-forgotten-export) The symbol "ResolveZodType" needs to be exported by the entry point index.d.ts
// src/routing/createRoute/createRoute.ts:316:9 - (ae-forgotten-export) The symbol "RouteRedirect" needs to be exported by the entry point index.d.ts
// src/routing/createRoute/createRoute.ts:288:19 - (ae-forgotten-export) The symbol "MergeRouteTypes" needs to be exported by the entry point index.d.ts
// src/routing/createRoute/createRoute.ts:288:19 - (ae-forgotten-export) The symbol "ResolveZodType" needs to be exported by the entry point index.d.ts
// src/routing/createRoute/createRoute.ts:325:9 - (ae-forgotten-export) The symbol "RouteRedirect" needs to be exported by the entry point index.d.ts
// src/types.ts:25:3 - (ae-incompatible-release-tags) The symbol "view" is marked as @public, but its signature references "MatchesFrom" which is marked as @internal
// src/types.ts:172:3 - (ae-incompatible-release-tags) The symbol "canHandleEvent" is marked as @public, but its signature references "CanHandleEvent" which is marked as @internal
// src/types.ts:173:3 - (ae-incompatible-release-tags) The symbol "inState" is marked as @public, but its signature references "MatchesFrom" which is marked as @internal
Expand Down

0 comments on commit 1468c77

Please sign in to comment.