Skip to content

Commit 1bcdd0c

Browse files
henrymercerCopilot
andcommitted
Derive the API client type from @actions/github
`ApiClient` was hand-composed from `Octokit`, `Api` and `PaginateInterface`, imported directly from separately versioned Octokit packages. That asserted a shape matching what `@actions/github` actually returns, which held only while the versions happened to agree. `@octokit/plugin-rest-endpoint-methods` v18 adds twelve Actions cache-limit methods. `@actions/github` still depends on `^17.0.0`, so the client it constructs no longer satisfies the v18-derived alias and the build fails. Deriving the type from the constructor removes the assumption, so the alias tracks whatever `@actions/github` returns. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 25694c0 commit 1bcdd0c

3 files changed

Lines changed: 10 additions & 16 deletions

File tree

lib/entry-points.js

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pr-checks/api-client.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import * as githubUtils from "@actions/github/lib/utils";
2-
import { type Octokit } from "@octokit/core";
3-
import { type PaginateInterface } from "@octokit/plugin-paginate-rest";
4-
import { type Api } from "@octokit/plugin-rest-endpoint-methods";
52

63
/** The type of the Octokit client. */
7-
export type ApiClient = Octokit & Api & { paginate: PaginateInterface };
4+
export type ApiClient = InstanceType<typeof githubUtils.GitHub>;
85

96
/** Constructs an `ApiClient` using `token` for authentication. */
107
export function getApiClient(token: string): ApiClient {

src/api-client.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import * as core from "@actions/core";
22
import * as githubUtils from "@actions/github/lib/utils";
3-
import { type Octokit } from "@octokit/core";
4-
import { type PaginateInterface } from "@octokit/plugin-paginate-rest";
5-
import { type Api } from "@octokit/plugin-rest-endpoint-methods";
63
import * as retry from "@octokit/plugin-retry";
74
import { RequestRequestOptions } from "@octokit/types";
85
import {
@@ -128,7 +125,7 @@ export function makeProxyRequestOptions(
128125
}
129126

130127
/** The type of GitHub API client we use. */
131-
export type ApiClient = Octokit & Api & { paginate: PaginateInterface };
128+
export type ApiClient = InstanceType<typeof githubUtils.GitHub>;
132129

133130
/** Options for `createApiClientWithDetails`. */
134131
interface CreateApiClientOptions {

0 commit comments

Comments
 (0)