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

Octokit typing slightly broken on TS 4.3 #62

Closed
3 of 7 tasks
angelsl opened this issue Jun 10, 2021 · 3 comments
Closed
3 of 7 tasks

Octokit typing slightly broken on TS 4.3 #62

angelsl opened this issue Jun 10, 2021 · 3 comments
Labels
Type: Bug Something isn't working as documented typescript

Comments

@angelsl
Copy link

angelsl commented Jun 10, 2021

Checklist

Environment

  • https://api.github.com
  • GitHub Enterprise Server:
  • GitHub Enterprise Cloud
  • Node.js
  • Browsers:
  • Others: TypeScript 4.3

Versions

18.5.6

What happened?

import { Octokit } from "@octokit/rest";

function test(a?: Octokit) {
  if (a === undefined) {
    return;
  }
  // `a` is now narrowed to `never`

  const r = a.repos; // typechecking fails as `never` has no property `repos`
}

Playground link

This only happens in TS 4.3.

What should happen: a should not be narrowed to never

I suspect it is due to the type of Octokit being an intersection with void:

type Octokit = Core & void & {
    paginate: any;
} & RestEndpointMethods & Api
@angelsl angelsl added the Type: Bug Something isn't working as documented label Jun 10, 2021
@gr2m
Copy link
Contributor

gr2m commented Jun 10, 2021

I think this is a duplicate for octokit/octokit.js#2115, can we track it there?

@angelsl
Copy link
Author

angelsl commented Jun 10, 2021

Yeah, it is. Sorry, should've looked there too.

@angelsl angelsl closed this as completed Jun 10, 2021
@gr2m
Copy link
Contributor

gr2m commented Jun 10, 2021

no worries, you could not have known

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working as documented typescript
Projects
None yet
Development

No branches or pull requests

2 participants