Skip to content

Instantly share code, notes, and snippets.

@yusukebe
Created January 18, 2025 09:45
Show Gist options
  • Save yusukebe/23d5f6b35fb75d607e2b26c715fdeb40 to your computer and use it in GitHub Desktop.
Save yusukebe/23d5f6b35fb75d607e2b26c715fdeb40 to your computer and use it in GitHub Desktop.
diff --git a/src/types.ts b/src/types.ts
index 193f73ad..4225be41 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -1984,9 +1984,9 @@ export type ExtractSchema<T> = UnionToIntersection<
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>
: {}
////////////////////////////////////////
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment