octokit / request.js

Send parameterized requests to GitHub’s APIs with sensible defaults in browsers and Node
MIT License
224 stars 61 forks source link

[BUG]: With parseSuccessResponseBody set to false, the return type is improperly set #665

Closed danielhjacobs closed 5 months ago

danielhjacobs commented 5 months ago

What happened?

With this code:

  const asset = await octokit.rest.repos.getReleaseAsset({
    owner: repository.owner,
    repo: repository.repo,
    asset_id: asset_id,
    headers: {
      accept: "application/octet-stream",
    },
    request: {
      parseSuccessResponseBody: false, // required to access response as stream
    },
  });
  return await new Response(asset.data).json();

I got the error Argument of type '{ url: string; browser_download_url: string; id: number; node_id: string; name: string; label: string | null; state: "uploaded" | "open"; content_type: string; size: number; download_count: number; created_at: string; updated_at: string; uploader: { ...; } | null; }' is not assignable to parameter of type 'BodyInit | null | undefined'

Versions

Octokit 3.1.2, Node 20.

Relevant log output

No response

Code of Conduct

github-actions[bot] commented 5 months ago

👋 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! 🚀

wolfy1339 commented 5 months ago

We are aware of the issue. Already tracking it over in https://github.com/octokit/types.ts/issues/606

danielhjacobs commented 5 months ago

Closing as duplicate

wolfy1339 commented 4 months ago

I created a PR that helps with this issue, https://github.com/octokit/types.ts/issues/608