From 9ba55df97ed26692633e55fb433d51f1b3a2b8a7 Mon Sep 17 00:00:00 2001 From: olliethedev <3martynov@gmail.com> Date: Wed, 15 Oct 2025 14:41:46 -0400 Subject: [PATCH] fix: fix route type fix --- package.json | 2 +- src/router.ts | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index beb75d3..9fe384b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@btst/yar", - "version": "1.1.0", + "version": "1.1.1", "packageManager": "pnpm@10.14.0", "description": "Pluggable router for modern react frameworks", "type": "module", diff --git a/src/router.ts b/src/router.ts index e9e43be..3ff2eae 100644 --- a/src/router.ts +++ b/src/router.ts @@ -104,16 +104,13 @@ type ExtractRouteReturn = R extends (...args: any[]) => infer Return ? Return : never; -// Helper type to get the union of all route return types -type InferRouteReturnTypes> = { - [K in keyof Routes]: ExtractRouteReturn; -}[keyof Routes]; - -// The return type for getRoute, combining the handler return with params -type GetRouteReturn> = - InferRouteReturnTypes & { +// The return type for getRoute, combining each handler return with params +// We distribute the intersection over the union to preserve all properties +type GetRouteReturn> = { + [K in keyof Routes]: ExtractRouteReturn & { params: Record; }; +}[keyof Routes]; /** * Creates a router instance from a collection of routes.