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

[FEAT]: Discriminated unions for (issue timeline) events #619

Closed
1 task done
Artemoire opened this issue Feb 26, 2024 · 3 comments
Closed
1 task done

[FEAT]: Discriminated unions for (issue timeline) events #619

Artemoire opened this issue Feb 26, 2024 · 3 comments
Labels
Status: Up for grabs Issues that are ready to be worked on by anyone Type: Feature New feature or request

Comments

@Artemoire
Copy link

Describe the need

I have type safety issues with listEventsForTimeline operation where I have to use type casting with the as keyword in typescript based on switching the event type. Using the octokit/rest.js client, the code looks like this:

const response = await octokit.issues.listEventsForTimeline({
  owner: "OWNER",
  repo: "REPO",
  issue_number: PULL_NUMBER,
});
response.data.forEach( (item) => {
  if (item.event === "reviewed") {
    // here is the issue: need to type cast the item in order to get the underlying type.
    const reviewedEvent = item as components["schemas"]["timeline-reviewed-event"];
  }
});

It would be useful if discriminated unions were used instead to provide type switching by definition. I put the issue timeline in the title in parentheses as I'm not sure if there are other component schemas that can benefit from this approach.

I assume the component schemas are generated from the API documentation, so I'm not sure if this is possible.

....On an unrelated note, can anyone tell me where I can report bugs for the GitHub API and/or where I can request documentation for undocumented APIs.

SDK Version

No response

API Version

No response

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@Artemoire Artemoire added Status: Triage This is being looked at and prioritized Type: Feature New feature or request labels Feb 26, 2024
Copy link
Contributor

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

@kfcampbell kfcampbell moved this from 🆕 Triage to 🔥 Backlog in 🧰 Octokit Active Mar 4, 2024
@kfcampbell kfcampbell added Status: Up for grabs Issues that are ready to be worked on by anyone and removed Status: Triage This is being looked at and prioritized labels Mar 4, 2024
@kfcampbell
Copy link
Member

....On an unrelated note, can anyone tell me where I can report bugs for the GitHub API and/or where I can request documentation for undocumented APIs.

In the past, we've pointed people here to make requests for API features and bugs.

@wolfy1339
Copy link
Member

As you've noted, we generate our code and typings from the API documentation. We can apply some overrides to correct data in the mean time until GitHub fixes it, but not adding entirely new features.

I have made a request already for them to include them github/rest-api-description#1318

@wolfy1339 wolfy1339 closed this as not planned Won't fix, can't repro, duplicate, stale Nov 20, 2024
@github-project-automation github-project-automation bot moved this from 🔥 Backlog to ✅ Done in 🧰 Octokit Active Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Up for grabs Issues that are ready to be worked on by anyone Type: Feature New feature or request
Projects
Status: Done
Development

No branches or pull requests

3 participants