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

Generated response types are incorrect for some values #64

Closed
joeyj-deliveroo opened this issue Apr 9, 2020 · 5 comments
Closed

Generated response types are incorrect for some values #64

joeyj-deliveroo opened this issue Apr 9, 2020 · 5 comments
Labels
Type: Bug Something isn't working as documented

Comments

@joeyj-deliveroo
Copy link

What happened?

Current entry in @octokit/plugin-rest-endpoint-methods/dist-types/generated/types.d.ts:

declare type SearchIssuesAndPullRequestsResponseItemsItem = {
    assignee: null;
    body: string;
    closed_at: null;
    comments: number;
    comments_url: string;
    created_at: string;
    events_url: string;
    html_url: string;
    id: number;
    labels: Array<SearchIssuesAndPullRequestsResponseItemsItemLabelsItem>;
    labels_url: string;
    milestone: null;
    node_id: string;
    number: number;
    pull_request: SearchIssuesAndPullRequestsResponseItemsItemPullRequest;
    repository_url: string;
    score: number;
    state: string;
    title: string;
    updated_at: string;
    url: string;
    user: SearchIssuesAndPullRequestsResponseItemsItemUser;
};

What did you expect to happen?

I'd expect closed_at to be string | null. I'm unsure about the other null types as well.

@joeyj-deliveroo joeyj-deliveroo added the Type: Bug Something isn't working as documented label Apr 9, 2020
@gr2m gr2m changed the title Generated type for SearchIssuesAndPullRequestsResponseItemsItem is incorrect Generated response types are incorrect for some values Apr 9, 2020
@gr2m
Copy link
Contributor

gr2m commented Apr 9, 2020

These types are currently automatically generated from the documentation at https://developer.github.com/v3/, via https://github.com/octokit/routes/. In this particular case from the response at https://developer.github.com/v3/search/#example-3.

We are looking into ways to get better response schemas, but for the time being this is the best we can do.

You'll have to manually overwrite the type, e.g. response.data.closedAt as string

@ockham
Copy link

ockham commented Feb 15, 2021

FWIW, I'm facing the same issue (closed_at being typed as null) with IssuesListForRepoResponseItem.

@wolfy1339
Copy link
Member

@ockham What version are you using?

The types are generated from GitHub's OpenAPI spec for the REST API now, can you check the endpoint there and see if the problem is there as well

@ockham
Copy link

ockham commented Feb 16, 2021

@ockham What version are you using?

16.26.0

The types are generated from GitHub's OpenAPI spec for the REST API now, can you check the endpoint there and see if the problem is there as well

Ah, I wasn't aware, thanks for the pointer!

The latest version -- v18.1.1-- seems to have the right type for issues list items indeed (with the closed_at field's type set to a string) 🎉 But alas, the new type format doesn't seem to work too well with TS-in-JSDoc 😕 I've filed an experimental PR, describing the issue in the PR desc, if either of you could maybe have a quick look 😊

Is there any other (more JSDoc-compatible) way to access these types?

@wolfy1339 wolfy1339 removed the blocked label Feb 17, 2021
@wolfy1339
Copy link
Member

I believe that the original issue here has been resolved.

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
Projects
None yet
Development

No branches or pull requests

4 participants