From ba13f4e3c745dcf7484d45a6cbb16edc2541a411 Mon Sep 17 00:00:00 2001 From: Hernan Alvarado Date: Thu, 4 Jun 2026 19:07:36 -0500 Subject: [PATCH 1/3] feat(types)!: remove TypeBox schema type inference BREAKING CHANGE: Automatic type inference from TypeBox schemas has been removed. Runtime schema validation remains supported. --- src/@types/client.ts | 4 ++-- test/client.test.ts | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/@types/client.ts b/src/@types/client.ts index 0d776a0..957f957 100644 --- a/src/@types/client.ts +++ b/src/@types/client.ts @@ -1,6 +1,5 @@ import type { Type } from "arktype" import type { ObjectSchema } from "valibot" -import type { Static, TSchema } from "typebox" import type { RequestHeaders } from "@/@types/http.ts" import type { infer as Infer } from "zod/v4/core" import type { InferValibotSchema, SchemaKind, SupportedSchema } from "@/@types/schemas.ts" @@ -11,7 +10,7 @@ export type InferSchema> = Kind extends "zod" : Kind extends "valibot" ? InferValibotSchema> : Kind extends "typebox" - ? Static + ? T : [T] extends [Type] ? U : T @@ -43,6 +42,7 @@ type InferContent> = ? RemoveUndefined> : unknown : unknown + /** * Generates a client type based on the provided route endpoints. Each endpoint's method and route are * used to create a corresponding function to access the endpoint. diff --git a/test/client.test.ts b/test/client.test.ts index 0eee621..6617a63 100644 --- a/test/client.test.ts +++ b/test/client.test.ts @@ -528,22 +528,29 @@ test("Client type inference with TypeBox schemas", async () => { } ) - const router = createRouter([getItem, createItem, deleteItem]) + const getItems = createEndpoint("GET", "/items", (ctx) => { + return ctx.json({ method: ctx.method }) + }) + + const router = createRouter([getItem, createItem, deleteItem, getItems]) const client = createClient({ baseURL: "http://api.example.com", }) + // @ts-expect-error invalid typebox support. client.get("/items/:itemId", { params: { itemId: "123", }, }) + // @ts-expect-error invalid typebox support. client.get("/items/:itemId", { params: { itemId: "123" }, }) + // @ts-expect-error invalid typebox support. const item = await client.get("/items/:itemId", { params: { itemId: "123" }, }) @@ -556,7 +563,9 @@ test("Client type inference with TypeBox schemas", async () => { expectTypeOf().toEqualTypeOf>() const deletedItem = await client.delete("/items/:itemId", { + // @ts-expect-error invalid typebox support. params: { itemId: "123" }, + // @ts-expect-error invalid typebox support. searchParams: { force: "true" }, }) expectTypeOf().toEqualTypeOf>() From c17ca22e54ad7a95d2cfae3fa7fea6a3d7ded75a Mon Sep 17 00:00:00 2001 From: Hernan Alvarado Date: Thu, 4 Jun 2026 20:04:13 -0500 Subject: [PATCH 2/3] fix(client): fix infered schemas in client functions --- src/@types/client.ts | 2 +- test/client.test.ts | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/@types/client.ts b/src/@types/client.ts index 957f957..2d3049c 100644 --- a/src/@types/client.ts +++ b/src/@types/client.ts @@ -10,7 +10,7 @@ export type InferSchema> = Kind extends "zod" : Kind extends "valibot" ? InferValibotSchema> : Kind extends "typebox" - ? T + ? {} : [T] extends [Type] ? U : T diff --git a/test/client.test.ts b/test/client.test.ts index 6617a63..6a2d8a8 100644 --- a/test/client.test.ts +++ b/test/client.test.ts @@ -538,19 +538,16 @@ test("Client type inference with TypeBox schemas", async () => { baseURL: "http://api.example.com", }) - // @ts-expect-error invalid typebox support. client.get("/items/:itemId", { params: { itemId: "123", }, }) - // @ts-expect-error invalid typebox support. client.get("/items/:itemId", { params: { itemId: "123" }, }) - // @ts-expect-error invalid typebox support. const item = await client.get("/items/:itemId", { params: { itemId: "123" }, }) @@ -563,9 +560,7 @@ test("Client type inference with TypeBox schemas", async () => { expectTypeOf().toEqualTypeOf>() const deletedItem = await client.delete("/items/:itemId", { - // @ts-expect-error invalid typebox support. params: { itemId: "123" }, - // @ts-expect-error invalid typebox support. searchParams: { force: "true" }, }) expectTypeOf().toEqualTypeOf>() From 14811f6666df077ff055766d81925cb1c5f02d8a Mon Sep 17 00:00:00 2001 From: Hernan Alvarado Date: Thu, 4 Jun 2026 20:22:53 -0500 Subject: [PATCH 3/3] chore: update `CHANGELOG.md` file --- CHANGELOG.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 550f37a..f3d9a17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,18 @@ Per-package version history is maintained inside each package’s own `CHANGELOG ## [Unreleased] +### Changed + +- Removed TypeBox compile-time type inference for `searchParams`, `params`, and `body` in client functions produced by `createClient`. Runtime validation with TypeBox remains supported, but `Static`-based inference is no longer used for client call signatures. [#54](https://github.com/aura-stack-ts/router/pull/54) + +--- + +## [0.7.1] - 2026-06-04 + +### Changed + +- Removed TypeBox compile-time type inference for `searchParams`, `params`, and `body` in endpoints and middlewares due to the performance cost of `Static` from the `typebox` package. Runtime validation with TypeBox remains supported. [#52](https://github.com/aura-stack-ts/router/pull/52) + --- ## [0.7.0] - 2026-05-13