Closed Codex- closed 8 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! 🚀
I just double checked the generated endpoints and types, and the URL parameters are set as required, the body parameters are all defined as you would expect.
Are you able to use Octokit directly instead of using @actions/github
in order to isolate the issue?
The same results for me when using the latest octokit
directly.
import type { Octokit } from "octokit";
// unknown
type owner = NonNullable<Parameters<Octokit["rest"]["checks"]["update"]>[0]>["owner"];
// Same results for the other expected types too
update
:
create
:
Thanks for confirming that. I can't seem to reproduce this myself.
In the Typescript transpilation of the OpenAPI spec everything seems fine.
Are you able to diagnose this?
The base types from @octokit/types
are correct, it's when we create method types over in @octokit/plugin-rest-endpoint-methods
where things start going foul.
You can see in my TypeScript playground the issue here.
The types for this endpoint in @octokit/plugin-rest-endpoint-methods
:
I have narrowed it down to the Omit<[...], "baseUrl" | "headers" | "mediaType">
It seems that TypeScript narrows it down to { [key: string]: unknown }
@gr2m Do you recall why the Omit
is there? The earliest that I can find it's usage is from https://github.com/octokit/plugin-rest-endpoint-methods.js/commit/7ed9fc41b3c714e851610111ae785841df0f77fd
Do you recall why the
Omit
is there
I don't, sorry 😞 "baseUrl" | "headers" | "mediaType"
are all generic request options, not specific to any rest API endpoint, I assume they are added back at a later point, so that the parameters
types are only containing types for the respective endpoint, without the generic ones
At that point there where the Omit
is currently, there doesn't seem to be any request related parameters. It's only the endpoint parameters themselves.
feel free to experiment and remove it, I was learning TypeScript as I was building this, it's likely that I messed things up. The types I built for https://github.com/octokit/octokit-next.js are more elegant 🤷 I really wish we could complete that work
I removed the Omit
from the types, and ran the tests for @octokit/rest
along with the tests for octokit
with the updated types and every test passes, including the typescript test.
I believe that that would alleviate this issue. I will prepare a PR to fix that
It seems we have run into this issue before: https://github.com/octokit/plugin-rest-endpoint-methods.js/issues/441
What happened?
I noticed this when trying to use
octokit.rest.checks.update
:I inspected the params further, comparing with
create
, usingstatus
as an example:Appears to be related to the type generation for
/repos/{owner}/{repo}/check-runs/{check_run_id}
The documentation indicates that
status
should be available, but trying to get any types for this endpoint results in unknown:Versions
Node 20.8.1
Relevant log output
No response
Code of Conduct