Skip to content

Commit ca5a378

Browse files
committed
fix types on passing request options
1 parent 8c350ab commit ca5a378

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/openapi-fetch/src/index.d.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -158,16 +158,16 @@ type PathMethods = Partial<Record<HttpMethod, {}>>;
158158
export type MaybeOptionalInit<P extends PathMethods, M extends keyof P> = HasRequiredKeys<
159159
FetchOptions<FilterKeys<P, M>>
160160
> extends never
161-
? [(FetchOptions<FilterKeys<P, M>> | undefined)?]
162-
: [FetchOptions<FilterKeys<P, M>>];
161+
? FetchOptions<FilterKeys<P, M>> | undefined
162+
: FetchOptions<FilterKeys<P, M>>;
163163

164164
export type ClientMethod<Paths extends Record<string, PathMethods>, M extends HttpMethod, Media extends MediaType> = <
165165
P extends PathsWithMethod<Paths, M>,
166166
I extends MaybeOptionalInit<Paths[P], M>,
167167
>(
168168
url: P,
169-
...init: I
170-
) => Promise<FetchResponse<Paths[P][M], I[0], Media>>;
169+
...init: HasRequiredKeys<I> extends never ? [I?] : [I]
170+
) => Promise<FetchResponse<Paths[P][M], I, Media>>;
171171

172172
export default function createClient<Paths extends {}, Media extends MediaType = MediaType>(
173173
clientOptions?: ClientOptions,

0 commit comments

Comments
 (0)