From 1468c77020f3d34be6aaccf986659a44a1ba8a80 Mon Sep 17 00:00:00 2001 From: Taylor Lodge Date: Wed, 24 Jan 2024 09:16:18 +1300 Subject: [PATCH 1/2] feat(routes): RouteQuery type Extracts query type from a route object --- src/index.ts | 1 + src/routing/createRoute/createRoute.ts | 9 +++++++++ src/routing/createRoute/index.ts | 1 + src/routing/index.ts | 1 + xstate-tree.api.md | 9 ++++++--- 5 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index 8d71f1d..7bd5679 100644 --- a/src/index.ts +++ b/src/index.ts @@ -14,6 +14,7 @@ export { type LinkProps, type AnyRoute, type RouteParams, + type RouteQuery, type RouteArguments, type Route, type RouteMeta, diff --git a/src/routing/createRoute/createRoute.ts b/src/routing/createRoute/createRoute.ts index 2a25ddf..36a9e11 100644 --- a/src/routing/createRoute/createRoute.ts +++ b/src/routing/createRoute/createRoute.ts @@ -247,6 +247,15 @@ export type RouteParams = T extends Route ? TParams : undefined; +/** + * @public + * + * Extract query type from route + */ +export type RouteQuery = T extends Route + ? TQuery + : undefined; + /** * @public * diff --git a/src/routing/createRoute/index.ts b/src/routing/createRoute/index.ts index 67cc5d9..af7dfa0 100644 --- a/src/routing/createRoute/index.ts +++ b/src/routing/createRoute/index.ts @@ -5,6 +5,7 @@ export { type RouteArguments, type RouteParams, type RouteMeta, + type RouteQuery, type ArgumentsForRoute, type Params, type Query, diff --git a/src/routing/index.ts b/src/routing/index.ts index 2befb9e..1b5f638 100644 --- a/src/routing/index.ts +++ b/src/routing/index.ts @@ -4,6 +4,7 @@ export { type AnyRoute, type RouteParams, type RouteMeta, + type RouteQuery, type RouteArguments, type ArgumentsForRoute, type Params, diff --git a/xstate-tree.api.md b/xstate-tree.api.md index fffb35e..32d6fbb 100644 --- a/xstate-tree.api.md +++ b/xstate-tree.api.md @@ -327,6 +327,9 @@ export type RouteMeta = T extends Route ? TMeta : // @public export type RouteParams = T extends Route ? TParams : undefined; +// @public +export type RouteQuery = T extends Route ? TQuery : undefined; + // @public (undocumented) export type Routing404Event = { type: "ROUTING_404"; @@ -476,9 +479,9 @@ export type XstateTreeMachineStateSchemaV2 Date: Tue, 23 Jan 2024 20:17:37 +0000 Subject: [PATCH 2/2] release(version): Release 4.6.0 [skip ci] # [4.6.0](https://github.com/koordinates/xstate-tree/compare/v4.5.0...v4.6.0) (2024-01-23) ### feat * **routes:** RouteQuery type ([1468c77](https://github.com/koordinates/xstate-tree/commit/1468c77020f3d34be6aaccf986659a44a1ba8a80)) --- CHANGELOG.md | 7 +++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 949e82f..1cdb668 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# [4.6.0](https://github.com/koordinates/xstate-tree/compare/v4.5.0...v4.6.0) (2024-01-23) + + +### feat + +* **routes:** RouteQuery type ([1468c77](https://github.com/koordinates/xstate-tree/commit/1468c77020f3d34be6aaccf986659a44a1ba8a80)) + # [4.5.0](https://github.com/koordinates/xstate-tree/compare/v4.4.0...v4.5.0) (2024-01-15) diff --git a/package-lock.json b/package-lock.json index ca80982..411981d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@koordinates/xstate-tree", - "version": "4.5.0", + "version": "4.6.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@koordinates/xstate-tree", - "version": "4.5.0", + "version": "4.6.0", "license": "MIT", "dependencies": { "fast-memoize": "^2.5.2", diff --git a/package.json b/package.json index 75201ae..a5e651e 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@koordinates/xstate-tree", "main": "lib/index.js", "types": "lib/xstate-tree.d.ts", - "version": "4.5.0", + "version": "4.6.0", "license": "MIT", "description": "Build UIs with Actors using xstate and React", "keywords": [