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 60bffbb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,11 @@ 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 +1992,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 60bffbb

Please sign in to comment.