Skip to content

Commit

Permalink
fix: correct the typings for moctokit (#82)
Browse files Browse the repository at this point in the history
* add non nullable to request body to fix keyof for optional properties

* remove export for RequestBody
  • Loading branch information
shubhbapna authored Dec 29, 2023
1 parent 3889ee6 commit c239947
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/moctokit/request/request-mocker.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ export type Parameters<T> = "parameters" extends keyof T
: Record<never, never>;

type RequestBody<T> = "requestBody" extends keyof T
? "content" extends keyof T["requestBody"]
? "application/json" extends keyof T["requestBody"]["content"]
? T["requestBody"]["content"]["application/json"]
? "content" extends keyof NonNullable<T["requestBody"]>
? "application/json" extends keyof NonNullable<T["requestBody"]>["content"]
? NonNullable<T["requestBody"]>["content"]["application/json"]
: {
data: {
[K in keyof T["requestBody"]["content"]]: T["requestBody"]["content"][K];
}[keyof T["requestBody"]["content"]];
[K in keyof NonNullable<T["requestBody"]>["content"]]: NonNullable<T["requestBody"]>["content"][K];
}[keyof NonNullable<T["requestBody"]>["content"]];
}
: "application/json" extends keyof T["requestBody"]
? T["requestBody"]["application/json"]
: "application/json" extends keyof NonNullable<T["requestBody"]>
? NonNullable<T["requestBody"]>["application/json"]
: {
data: {
[K in keyof T["requestBody"]]: T["requestBody"][K];
}[keyof T["requestBody"]];
[K in keyof NonNullable<T["requestBody"]>]: NonNullable<T["requestBody"]>[K];
}[keyof NonNullable<T["requestBody"]>];
}
: Record<never, never>;

Expand Down

0 comments on commit c239947

Please sign in to comment.