Skip to content

Commit

Permalink
perf(types): replace intersection with union to get better perf
Browse files Browse the repository at this point in the history
  • Loading branch information
m-shaka committed Sep 23, 2024
1 parent e1eb98d commit 06610f8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export type ErrorHandler<E extends Env = any> = (
////// //////
////////////////////////////////////////


export interface HandlerInterface<
E extends Env = Env,
M extends string = string,
Expand Down Expand Up @@ -146,7 +147,7 @@ export interface HandlerInterface<
>(
path: P,
handler: H<E2, MergedPath, I, R>
): Hono<E, S & ToSchema<M, MergePath<BasePath, P>, I, MergeTypedResponse<R>>, BasePath>
): Hono<E, ExcludeEmptyObject<S | ToSchema<M, MergePath<BasePath, P>, I, MergeTypedResponse<R>>>, BasePath>

// app.get(handler x 3)
<
Expand Down Expand Up @@ -1988,6 +1989,8 @@ type IntersectNonAnyTypes<T extends any[]> = T extends [infer Head, ...infer Res
? IfAnyThenEmptyObject<EnvOrEmpty<Head>> & IntersectNonAnyTypes<Rest>
: {}

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

////////////////////////////////////////
////// //////
////// FetchEvent //////
Expand Down

0 comments on commit 06610f8

Please sign in to comment.