Skip to content

Commit

Permalink
fix: load all plugins while preserving type information provided to O…
Browse files Browse the repository at this point in the history
…ctokit (#1638)
  • Loading branch information
MaximDevoir authored Mar 10, 2020
1 parent 0d592e6 commit 1bdd177
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@ import { restEndpointMethods } from "@octokit/plugin-rest-endpoint-methods";

import { VERSION } from "./version";

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

0 comments on commit 1bdd177

Please sign in to comment.