-
Notifications
You must be signed in to change notification settings - Fork 1k
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]: Export friendly types for use in TS #2598
Comments
👋 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 |
The types and methods are automatically generated from the OpenAPI spec. You can already get the types for a specific endpoint via import { Endpoints } from "@octokit/types";
type ListWorkflowRunResponsePayload = Endpoints["GET /repos/{owner}/{repo}/actions/runs"]["response"];
function doSomethingWithWorkflow(workflow: ListWorkflowRunResponsePayload) {
//Do something
} |
Thanks, I didn't know about that package. It'd still be nice to have concise wrapper types, as in your example, but this will work for now. Or perhaps type Workflow: RestEndpointMethodTypes[ "actions" ][ "listWorkflowRuns" ][ "response" ][ "data" ][ "workflows" ][ 0 ]; Instead of: type Workflow = Endpoints[ "GET /repos/{owner}/{repo}/actions/workflows" ][ "response" ][ "data" ][ "workflows" ][ 0 ]; |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
There is always this way to do it as well import { Api } from "@octokit/plugin-rest-endpoint-methods";
type workflow = Awaited<ReturnType<Api["rest"]["actions"]["listRepoWorkflows"]>>['data']['workflows'][0]; or even import type { Octokit } from "octokit";
type workflow = Awaited<ReturnType<InstanceType<typeof Octokit>["rest"]["actions"]["listRepoWorkflows"]>>['data']['workflows'][0]; |
Describe the need
Perhaps I'm missing something, but If I want to write a function that takes in a result of an API call, I can't currently type that parameter. For example:
How can I type the
workflow
parameter? Looking in the types, I could do:But
RestEndpointMethodTypes
is not exported. And it'd be far better to have a type alias e.g.workflow: typeof ListWorkflowRunsResponsePayload[0]
.For now, I can get around this by indicating the things I want from the workflow:
But I assume I'm missing something here...
SDK Version
3.1.2
API Version
No response
Relevant log output
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: