mirror of
https://github.com/honojs/hono.git
synced 2024-12-01 11:51:01 +01:00
fix(client): ignore header
and cookie
types (#1359)
* fix(client): ignore `header` and `cookie` types * denoify
This commit is contained in:
parent
07bc29ee60
commit
2b274662e9
@ -22,7 +22,11 @@ type ClientRequest<S extends Data> = {
|
||||
[M in keyof S]: S[M] extends { input: infer R; output: infer O }
|
||||
? RemoveBlankRecord<R> extends never
|
||||
? (args?: {}, options?: ClientRequestOptions) => Promise<ClientResponse<O>>
|
||||
: (args: R, options?: ClientRequestOptions) => Promise<ClientResponse<O>>
|
||||
: (
|
||||
// Client does not support `header` and `cookie`
|
||||
args: Omit<R, 'header' | 'cookie'>,
|
||||
options?: ClientRequestOptions
|
||||
) => Promise<ClientResponse<O>>
|
||||
: never
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,7 @@ export interface HandlerInterface<
|
||||
I extends Input = {},
|
||||
I2 extends Input = I,
|
||||
I3 extends Input = I & I2,
|
||||
I4 extends Input = I2 & I3
|
||||
I4 extends Input = I & I2 & I3
|
||||
>(
|
||||
...handlers: [H<E, P, I, O>, H<E, P, I2, O>, H<E, P, I3, O>, H<E, P, I4, O>]
|
||||
): Hono<E, RemoveBlankRecord<S | Schema<M, P, I4['in'], O>>, BasePath>
|
||||
@ -111,7 +111,7 @@ export interface HandlerInterface<
|
||||
I2 extends Input = I,
|
||||
I3 extends Input = I & I2,
|
||||
I4 extends Input = I2 & I3,
|
||||
I5 extends Input = I3 & I4
|
||||
I5 extends Input = I & I2 & I3 & I4
|
||||
>(
|
||||
...handlers: [H<E, P, I, O>, H<E, P, I2, O>, H<E, P, I3, O>, H<E, P, I4, O>, H<E, P, I5, O>]
|
||||
): Hono<E, RemoveBlankRecord<S | Schema<M, P, I5['in'], O>>, BasePath>
|
||||
@ -156,7 +156,7 @@ export interface HandlerInterface<
|
||||
I extends Input = {},
|
||||
I2 extends Input = I,
|
||||
I3 extends Input = I & I2,
|
||||
I4 extends Input = I2 & I3
|
||||
I4 extends Input = I & I2 & I3
|
||||
>(
|
||||
path: P,
|
||||
...handlers: [
|
||||
@ -175,7 +175,7 @@ export interface HandlerInterface<
|
||||
I2 extends Input = I,
|
||||
I3 extends Input = I & I2,
|
||||
I4 extends Input = I2 & I3,
|
||||
I5 extends Input = I3 & I4
|
||||
I5 extends Input = I & I2 & I3 & I4
|
||||
>(
|
||||
path: P,
|
||||
...handlers: [
|
||||
@ -430,7 +430,9 @@ export type UndefinedIfHavingQuestion<T> = T extends `${infer _}?` ? string | un
|
||||
////// //////
|
||||
////////////////////////////////////////
|
||||
|
||||
export type ExtractSchema<T> = UnionToIntersection<T extends Hono<infer _, infer S, any> ? S : never>
|
||||
export type ExtractSchema<T> = UnionToIntersection<
|
||||
T extends Hono<infer _, infer S, any> ? S : never
|
||||
>
|
||||
|
||||
////////////////////////////////////////
|
||||
////// //////
|
||||
|
@ -25,6 +25,18 @@ describe('Basic - JSON', () => {
|
||||
const route = app
|
||||
.post(
|
||||
'/posts',
|
||||
// Client does not support `cookie`
|
||||
validator('cookie', () => {
|
||||
return {} as {
|
||||
debug: string
|
||||
}
|
||||
}),
|
||||
// Client does not support `header`
|
||||
validator('header', () => {
|
||||
return {} as {
|
||||
'x-request-id': string
|
||||
}
|
||||
}),
|
||||
validator('json', () => {
|
||||
return {} as {
|
||||
id: number
|
||||
|
@ -22,7 +22,11 @@ type ClientRequest<S extends Data> = {
|
||||
[M in keyof S]: S[M] extends { input: infer R; output: infer O }
|
||||
? RemoveBlankRecord<R> extends never
|
||||
? (args?: {}, options?: ClientRequestOptions) => Promise<ClientResponse<O>>
|
||||
: (args: R, options?: ClientRequestOptions) => Promise<ClientResponse<O>>
|
||||
: (
|
||||
// Client does not support `header` and `cookie`
|
||||
args: Omit<R, 'header' | 'cookie'>,
|
||||
options?: ClientRequestOptions
|
||||
) => Promise<ClientResponse<O>>
|
||||
: never
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,7 @@ export interface HandlerInterface<
|
||||
I extends Input = {},
|
||||
I2 extends Input = I,
|
||||
I3 extends Input = I & I2,
|
||||
I4 extends Input = I2 & I3
|
||||
I4 extends Input = I & I2 & I3
|
||||
>(
|
||||
...handlers: [H<E, P, I, O>, H<E, P, I2, O>, H<E, P, I3, O>, H<E, P, I4, O>]
|
||||
): Hono<E, RemoveBlankRecord<S | Schema<M, P, I4['in'], O>>, BasePath>
|
||||
@ -111,7 +111,7 @@ export interface HandlerInterface<
|
||||
I2 extends Input = I,
|
||||
I3 extends Input = I & I2,
|
||||
I4 extends Input = I2 & I3,
|
||||
I5 extends Input = I3 & I4
|
||||
I5 extends Input = I & I2 & I3 & I4
|
||||
>(
|
||||
...handlers: [H<E, P, I, O>, H<E, P, I2, O>, H<E, P, I3, O>, H<E, P, I4, O>, H<E, P, I5, O>]
|
||||
): Hono<E, RemoveBlankRecord<S | Schema<M, P, I5['in'], O>>, BasePath>
|
||||
@ -156,7 +156,7 @@ export interface HandlerInterface<
|
||||
I extends Input = {},
|
||||
I2 extends Input = I,
|
||||
I3 extends Input = I & I2,
|
||||
I4 extends Input = I2 & I3
|
||||
I4 extends Input = I & I2 & I3
|
||||
>(
|
||||
path: P,
|
||||
...handlers: [
|
||||
@ -175,7 +175,7 @@ export interface HandlerInterface<
|
||||
I2 extends Input = I,
|
||||
I3 extends Input = I & I2,
|
||||
I4 extends Input = I2 & I3,
|
||||
I5 extends Input = I3 & I4
|
||||
I5 extends Input = I & I2 & I3 & I4
|
||||
>(
|
||||
path: P,
|
||||
...handlers: [
|
||||
|
Loading…
Reference in New Issue
Block a user