Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide type information #10

Open
tenjaa opened this issue Sep 14, 2022 · 2 comments
Open

Provide type information #10

tenjaa opened this issue Sep 14, 2022 · 2 comments
Labels
Type: Feature New feature or request
Projects

Comments

@tenjaa
Copy link

tenjaa commented Sep 14, 2022

What’s missing?

An easy to use type of the extension to octokit this plugin provides.

Why?

We are passing an octokit instance as constructor parameter.
To benefit of typing we want to set the type properly.

Alternatives you tried

We copied the type from the index.d.ts to build this workaround.

/**
 * from node_modules/@octokit/plugin-paginate-graphql/dist-types/index.d.ts
 */
export type GraphqlPaginationExtension = {
  graphql: import("@octokit/graphql/dist-types/types").graphql & {
    paginate: (<ResponseType_1 extends object = any>(query: string, initialParameters?: Record<string, any>) => Promise<ResponseType_1>) & {
      iterator: <ResponseType_2 = any>(query: string, initialParameters?: Record<string, any>) => {
        [Symbol.asyncIterator]: () => {
          next(): Promise<{
            done: boolean;
            value: ResponseType_2;
          }>;
        };
      };
    };
  };
}
  constructor(
    private readonly octokit: Octokit & GraphqlPaginationExtension,
    private readonly otherStuff: OtherStuff,
  ) {
  }
@tenjaa tenjaa added the feature label Sep 14, 2022
@ghost ghost added this to Features in JS Sep 14, 2022
@Dizotoff
Copy link

Thank you for this!

@ghost ghost moved this from Features to Inbox in JS Oct 31, 2022
@wolfy1339 wolfy1339 added the Type: Feature New feature or request label Dec 16, 2022
@ghost ghost moved this from Inbox to Features in JS Dec 16, 2022
@wolfy1339
Copy link
Member

You can do the following to get the returned interface type:

import { paginateGraphQL } from "@octokit/paginate-graphql";
import { Octokit } from "@octokit/core";

type PaginateGraphQLOctokit = Octokit & ReturnType<paginateGraphQL>;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature New feature or request
Projects
No open projects
JS
  
Features
Development

No branches or pull requests

4 participants