From 331166471c499e5a8f432fcb77936c3d4f699cfe Mon Sep 17 00:00:00 2001 From: m-shaka Date: Mon, 14 Oct 2024 19:44:07 +0900 Subject: [PATCH] fix(types): rm ExcludeEmptyObject to fix massively increased type instantiations (#3507) * fix: mv ExcludeEmptyObject to hono-base.ts * refactor: rm ExcludeEmptyObject --- perf-measures/type-check/client.ts | 2 +- src/client/types.ts | 3 ++- src/hono-base.ts | 7 +------ src/utils/types.ts | 2 -- 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/perf-measures/type-check/client.ts b/perf-measures/type-check/client.ts index 022a5bef..289ede0c 100644 --- a/perf-measures/type-check/client.ts +++ b/perf-measures/type-check/client.ts @@ -1,4 +1,4 @@ -import type { app } from './generated/app' import { hc } from '../../src/client' +import type { app } from './generated/app' const client = hc('/') diff --git a/src/client/types.ts b/src/client/types.ts index e64a98eb..7a345370 100644 --- a/src/client/types.ts +++ b/src/client/types.ts @@ -1,4 +1,5 @@ import type { Hono } from '../hono' +import type { HonoBase } from '../hono-base' import type { Endpoint, ResponseFormat, Schema } from '../types' import type { StatusCode, SuccessStatusCode } from '../utils/http-status' import type { HasRequiredKeys } from '../utils/types' @@ -159,7 +160,7 @@ type PathToChain< } // eslint-disable-next-line @typescript-eslint/no-explicit-any -export type Client = T extends Hono +export type Client = T extends HonoBase ? S extends Record ? K extends string ? PathToChain diff --git a/src/hono-base.ts b/src/hono-base.ts index 9597a33b..a10f28b6 100644 --- a/src/hono-base.ts +++ b/src/hono-base.ts @@ -26,7 +26,6 @@ import type { RouterRoute, Schema, } from './types' -import type { ExcludeEmptyObject } from './utils/types' import { getPath, getPathNoStrict, mergePath } from './utils/url' /** @@ -213,11 +212,7 @@ class Hono( path: SubPath, app: Hono - ): Hono< - E, - ExcludeEmptyObject> | S>, - BasePath - > { + ): Hono> | S, BasePath> { const subApp = this.basePath(path) app.routes.map((r) => { let handler diff --git a/src/utils/types.ts b/src/utils/types.ts index 4a9647e3..0c124785 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -97,5 +97,3 @@ export type IsAny = boolean extends (T extends never ? true : false) ? true : * @see https://github.com/Microsoft/TypeScript/issues/29729 */ export type StringLiteralUnion = T | (string & Record) - -export type ExcludeEmptyObject = T extends {} ? ({} extends T ? never : T) : T