Skip to content

Commit

Permalink
fix(types): rm ExcludeEmptyObject to fix massively increased type ins…
Browse files Browse the repository at this point in the history
…tantiations (#3507)

* fix: mv ExcludeEmptyObject to hono-base.ts

* refactor: rm ExcludeEmptyObject
  • Loading branch information
m-shaka authored Oct 14, 2024
1 parent bd9effe commit 3311664
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 10 deletions.
2 changes: 1 addition & 1 deletion perf-measures/type-check/client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { app } from './generated/app'
import { hc } from '../../src/client'
import type { app } from './generated/app'

const client = hc<typeof app>('/')
3 changes: 2 additions & 1 deletion src/client/types.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -159,7 +160,7 @@ type PathToChain<
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type Client<T> = T extends Hono<any, infer S, any>
export type Client<T> = T extends HonoBase<any, infer S, any>
? S extends Record<infer K, Schema>
? K extends string
? PathToChain<K, S>
Expand Down
7 changes: 1 addition & 6 deletions src/hono-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import type {
RouterRoute,
Schema,
} from './types'
import type { ExcludeEmptyObject } from './utils/types'
import { getPath, getPathNoStrict, mergePath } from './utils/url'

/**
Expand Down Expand Up @@ -213,11 +212,7 @@ class Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string =
>(
path: SubPath,
app: Hono<SubEnv, SubSchema, SubBasePath>
): Hono<
E,
ExcludeEmptyObject<MergeSchemaPath<SubSchema, MergePath<BasePath, SubPath>> | S>,
BasePath
> {
): Hono<E, MergeSchemaPath<SubSchema, MergePath<BasePath, SubPath>> | S, BasePath> {
const subApp = this.basePath(path)
app.routes.map((r) => {
let handler
Expand Down
2 changes: 0 additions & 2 deletions src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,3 @@ export type IsAny<T> = boolean extends (T extends never ? true : false) ? true :
* @see https://github.com/Microsoft/TypeScript/issues/29729
*/
export type StringLiteralUnion<T> = T | (string & Record<never, never>)

export type ExcludeEmptyObject<T> = T extends {} ? ({} extends T ? never : T) : T

0 comments on commit 3311664

Please sign in to comment.