Closed
Description
MaybeOptionalInit
now requires Paths[P] to be a complete record including every HttpMethod
. However, routes rarely have every method. I think it should be defined as Partial<Record<HttpMethod, {}>>
instead. The same with ClientMethod
:
export type MaybeOptionalInit<
P extends Partial<Record<HttpMethod, {}>>,
M extends keyof P,
> =
HasRequiredKeys<FetchOptions<FilterKeys<P, M>>> extends never
? [(FetchOptions<FilterKeys<P, M>> | undefined)?]
: [FetchOptions<FilterKeys<P, M>>];
export type ClientMethod<
Paths extends Record<string, Partial<Record<HttpMethod, {}>>>,
M extends HttpMethod,
> = <
P extends PathsWithMethod<Paths, M>,
I extends MaybeOptionalInit<Paths[P], M>,
>(
url: P,
...init: I
) => Promise<FetchResponse<Paths[P][M], I[0]>>;