Skip to content

Commit

Permalink
Fix PathMethod object types (#1585)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikestopcontinues committed Mar 6, 2024
1 parent f7ce0f5 commit 4e06f86
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/funny-keys-judge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"openapi-fetch": patch
---

Update types for path-methods object
9 changes: 4 additions & 5 deletions packages/openapi-fetch/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,17 +169,16 @@ export interface Middleware {
onResponse?: typeof onResponse;
}

type PathMethods = Partial<Record<HttpMethod, {}>>;

/** This type helper makes the 2nd function param required if params/requestBody are required; otherwise, optional */
export type MaybeOptionalInit<
P extends Record<HttpMethod, {}>,
M extends keyof P,
> =
export type MaybeOptionalInit<P extends PathMethods, 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, Record<HttpMethod, {}>>,
Paths extends Record<string, PathMethods>,
M extends HttpMethod,
> = <
P extends PathsWithMethod<Paths, M>,
Expand Down

0 comments on commit 4e06f86

Please sign in to comment.