Skip to content
New issue

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

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

Already on GitHub? # to your account

TypeScript definitions for GitHub of @actions/github broken #365

Closed
LukasBombach opened this issue Feb 28, 2020 · 3 comments
Closed

TypeScript definitions for GitHub of @actions/github broken #365

LukasBombach opened this issue Feb 28, 2020 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@LukasBombach
Copy link

LukasBombach commented Feb 28, 2020

Describe the bug
The TypeScript definitions for GitHub of @actions/github are almost entirely wrong. They export a class with a single public method called graphql the takes an object of options.

This does not reflect the documentation or the actual library at all.

The documentation says you can do the following things:

import { GitHub } from "@actions/github"
const octokit = new github.GitHub(myToken);

octokit.pulls.get(/* ... */);
octokit.issues.create(/* ... */);
octokit.graphql(query, variables);

Instead TypeScript says the octokit only has a single method called graphql expecting a single parameter only.

To Reproduce

  1. yarn init -y
  2. yarn add @actions/github
  3. touch index.ts
  4. open index.ts add the following code
    import { GitHub } from "@actions/github"
    
    const x: any = null;
    
    const octokit = new github.GitHub(x);
    
    octokit.pulls.get(x);
    octokit.issues.create(x);
    octokit.graphql(x, x);

Expected behavior
TypeScript will reflect the API of the library and match the documentation

Desktop (please complete the following information):

  • OS: macOS Catalina
  • Browser Node.js
  • Version 12 lts
@LukasBombach LukasBombach added the bug Something isn't working label Feb 28, 2020
@LukasBombach LukasBombach changed the title TypeScript definitions for GitHub of @actions/github almost entirely wrong TypeScript definitions for GitHub of @actions/github broken Feb 28, 2020
@LukasBombach
Copy link
Author

The problem appears to be that your generated types import Octokit wrong, like so:

import Octokit from '@octokit/rest';

while it should be imported like this:

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

not sure why your build does that

@thboop thboop self-assigned this Mar 2, 2020
@thboop
Copy link
Collaborator

thboop commented Mar 2, 2020

Hey @LukasBombach , thanks for the report!

What version of @actions/github are you using?
We rolled out a fix for this in 2.1.1. #332

I've been unable to reproduce in 2.1.1 with your snippet (with one minor edit)

import { GitHub } from "@actions/github"

const x: any = null;

const octokit = new GitHub(x);

octokit.pulls.get(x);
octokit.issues.create(x);
octokit.graphql(x, x);

@LukasBombach
Copy link
Author

Yes! I can confirm it's fixed! Thank you so much! <3

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants