Skip to content

[FEAT]: Export friendly types for use in TS #2598

Open
@JoshMcCullough

Description

@JoshMcCullough

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:

const workflow = await octokit.rest.actions
    .listWorkflowRun(...)
    .then(r => r.data.workflows[0]);

doSomethingWithWorkflow(workflow);

function doSomethingWithWorkflow(workflow: ???) {
    // do something with the workflow
}

How can I type the workflow parameter? Looking in the types, I could do:

workflow: RestEndpointMethodTypes["actions"]["listWorkflowRuns"]["response"]["data"]["workflows"][0]

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:

workflow: { id: number, name: string }

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

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: Up for grabsIssues that are ready to be worked on by anyoneType: FeatureNew feature or request

    Type

    No type

    Projects

    Status

    🔥 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions