0
0
mirror of https://github.com/honojs/hono.git synced 2024-11-21 18:18:57 +01:00

fix(types): rm ExcludeEmptyObject to fix massively increased type instantiations (#3507)

* fix: mv ExcludeEmptyObject to hono-base.ts

* refactor: rm ExcludeEmptyObject
This commit is contained in:
m-shaka 2024-10-14 19:44:07 +09:00 committed by GitHub
parent bd9effe34f
commit 331166471c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 4 additions and 10 deletions

View File

@ -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>('/')

View File

@ -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> = 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>

View File

@ -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<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

View File

@ -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