Skip to content

Commit 1bdd177

Browse files
authored
fix: load all plugins while preserving type information provided to Octokit (#1638)
1 parent 0d592e6 commit 1bdd177

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/index.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,15 @@ import { restEndpointMethods } from "@octokit/plugin-rest-endpoint-methods";
55

66
import { VERSION } from "./version";
77

8-
export const Octokit = Core
9-
// TODO: this really should be
8+
export const Octokit = Core.plugin([
9+
// Workaround to prevent TypeScript from widening the inferred return type of
10+
// plugins passed to Octokit, which would result in type information (e.g.
11+
// methods provided by plugins) not being added to Octokit instances.
1012
//
11-
// .plugin([requestLog, paginateRest, restEndpointMethods])
12-
//
13-
// but for mystical reasons, using the line above does set the resulting the
14-
// `octokit` instance type correctly. Neither `octokit.paginate()` nor all the
15-
// endpoint methods such as `octokit.repos.get() are set
16-
.plugin(requestLog)
17-
.plugin([paginateRest, restEndpointMethods])
18-
.defaults({
19-
userAgent: `octokit-rest.js/${VERSION}`
20-
});
13+
// See https://github.com/octokit/core.js/issues/51#issuecomment-596846088
14+
(requestLog as unknown) as () => void,
15+
restEndpointMethods,
16+
paginateRest
17+
]).defaults({
18+
userAgent: `octokit-rest.js/${VERSION}`
19+
});

0 commit comments

Comments
 (0)