Skip to content

TypeScript types appear to be incorrect for paginate() on apps.listReposAccessibleToInstallation #350

@reececomo

Description

@reececomo

Hey there.

When running await paginate(...) on apps.listReposAccessibleToInstallation, the TypeScript inferred data type is not correct.

  // context is an Octokit with an installation.id

  const repos = await context.paginate(context.apps.listReposAccessibleToInstallation, {
    per_page: 100,
  });

  // TypeScript compiler/VSCode sees `repos` as:
  // {
  //   total_count: number,
  //   repositories: { id: number,  /*...*/ }[ ],
  //   repository_selection: ?string
  // }

But really at runtime it contains repositories data array:

  console.log(repos)
  // [
  //   { id: 123,  /*...*/ },
  //   { id: 456,  /*...*/ }
  // ]

Workaround

  // FIXME: Have been doing this as a workaround.
  const installationRepos = repos.repositories ?? repos;

  installationRepos.forEach(/*...*/);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: Needs infoFull requirements are not yet known, so implementation should not be startedType: BugSomething isn't working as documentedreleased

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions