Skip to content

Commit

Permalink
perf(type): improve Utilities in types.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
yusukebe committed Jan 18, 2025
1 parent 502709f commit cd91be3
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1980,13 +1980,11 @@ export type RemoveQuestion<T> = T extends `${infer R}?` ? R : T
////// //////
////////////////////////////////////////

export type ExtractSchema<T> = UnionToIntersection<
T extends HonoBase<infer _, infer S, any> ? S : never
>
export type ExtractSchema<T> = T extends HonoBase<infer _, infer S, any> ? S : never

type EnvOrEmpty<T> = T extends Env ? (Env extends T ? {} : T) : T
type ProcessHead<T> = IfAnyThenEmptyObject<T extends Env ? (Env extends T ? {} : T) : T>
export type IntersectNonAnyTypes<T extends any[]> = T extends [infer Head, ...infer Rest]
? IfAnyThenEmptyObject<EnvOrEmpty<Head>> & IntersectNonAnyTypes<Rest>
? ProcessHead<Head> & IntersectNonAnyTypes<Rest>
: {}

////////////////////////////////////////
Expand Down

0 comments on commit cd91be3

Please sign in to comment.