Skip to content

Commit 4e06f86

Browse files
Fix PathMethod object types (#1585)
1 parent f7ce0f5 commit 4e06f86

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

.changeset/funny-keys-judge.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"openapi-fetch": patch
3+
---
4+
5+
Update types for path-methods object

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

+4-5
Original file line numberDiff line numberDiff line change
@@ -169,17 +169,16 @@ export interface Middleware {
169169
onResponse?: typeof onResponse;
170170
}
171171

172+
type PathMethods = Partial<Record<HttpMethod, {}>>;
173+
172174
/** This type helper makes the 2nd function param required if params/requestBody are required; otherwise, optional */
173-
export type MaybeOptionalInit<
174-
P extends Record<HttpMethod, {}>,
175-
M extends keyof P,
176-
> =
175+
export type MaybeOptionalInit<P extends PathMethods, M extends keyof P> =
177176
HasRequiredKeys<FetchOptions<FilterKeys<P, M>>> extends never
178177
? [(FetchOptions<FilterKeys<P, M>> | undefined)?]
179178
: [FetchOptions<FilterKeys<P, M>>];
180179

181180
export type ClientMethod<
182-
Paths extends Record<string, Record<HttpMethod, {}>>,
181+
Paths extends Record<string, PathMethods>,
183182
M extends HttpMethod,
184183
> = <
185184
P extends PathsWithMethod<Paths, M>,

0 commit comments

Comments
 (0)