-
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
[BUG]: Typescript error on paginate string input #2439
Comments
This is probably due to the fact that OpenAPI updates haven't been made on the regular. |
Can you update your Octokit modules, and lockfiles? Then check if the problem is still present |
@wolfy1339 still having an issue. Building with
Code is the same as before, except for the addition of the const alerts: Array<DependabotAlert> = await octokit.paginate(
"GET /orgs/{org}/dependabot/alerts",
{
org: GITHUB_ORG,
per_page: 100,
headers: {
"X-GitHub-Api-Version": "2022-11-28",
},
state: "open"
},
(response) =>
response.data.map(
(item) =>
<DependabotAlert>{
...
}
)
); Versions based on updated
This is not a huge deal for me btw. I've just ignored this line with |
That's strange, that endpoint is defined in this package. |
I think I might have an idea why that's happening. I'll try pushing an update with updated plugins |
🎉 This issue has been resolved in version 2.0.16 🎉 The release is available on: Your semantic-release bot 📦🚀 |
@josherickson |
Still no, same or similar error. Here are my new versions based on updated
Here's a simplified snippet that gives the typescript build error: import { Octokit } from "octokit";
export async function getDependabotAlerts(): Promise<void> {
const octokit = new Octokit({ auth: process.env.GH_TOKEN });
await octokit.paginate(
"GET /orgs/{org}/dependabot/alerts",
{
org: "MyOrg",
per_page: 100,
headers: {
"X-GitHub-Api-Version": "2022-11-28",
},
state: "open",
},
(response) => console.log(response)
);
} Full error:
|
The types are expecting you to return an array in your function that logs the request in your simplified code import { Octokit } from "octokit";
export async function getDependabotAlerts(): Promise<void> {
const octokit = new Octokit({ auth: process.env.GH_TOKEN });
await octokit.paginate(
"GET /orgs/{org}/dependabot/alerts",
{
org: "octokit"
},
(response) => {
console.log(response);
return [];
}
); However, whenever I try to add the |
This code snippet works, it's simply when passing the route as a URL that it doesn't accept request parameters import { Octokit } from "octokit";
export async function getDependabotAlerts(): Promise<void> {
const octokit = new Octokit({ auth: process.env.GH_TOKEN });
await octokit.paginate(
octokit.rest.dependabot.listAlertsForOrg,
{
org: "MyOrg",
per_page: 100,
headers: {
"X-GitHub-Api-Version": "2022-11-28",
},
state: "open",
},
(response) => {
console.log(response);
return [];
}
);
} |
Probably relevant here... it seems like octokit.paginate.iterator(octokit.rest.repos.listReleases, { ... }) Failing with (pardon my French):
The error here happens because It would appear to me that this change of dependency in |
That happens all the time when the type version of different modules mismatch for any reason, whether the changes are breaking or not. It will get fixed over time, we still have other modules to get new major versions |
Is this problem being fixed anytime soon? I know the lib still works regardless of this error, but I prefer not having any @ts-ignore comments on my code. |
Please be patient with us, we have many repos to take care of. Changes are being worked on and pushed through. We had a hold up because of a problem that came up with our switch to the fetch API from |
@Harukisatoh The issue that was brought in this comment: #2439 (comment) is not related to this bug report It has been happening before that comment |
Hey @wolfy1339, I'm sorry man, I didn't mean to be rude or anything, I appreciate the work you do with this lib. Do we have a opened issue and a solution for the #2439 already? I tried to find it, but I couldn't. It seems that this issue is the most similar one. |
Unfortunately I don't believe an issue has been found yet. Can you test the latest versions? |
Hey, is this issue solved completely? |
There hasn't been any new comments or issues saying otherwise. |
In case it helps anyone, I am encountering the same with It looks like the So this gives an error: const members = await octokit.paginate('GET /orgs/{org}/members', {
org,
per_page: 50,
headers: {
'X-GitHub-Api-Version': '2022-11-28',
}
}) with the same confusing message, which highlight the route as being wrong
However, this works: const members = await octokit.paginate('GET /orgs/{org}/members', {
org,
per_page: 50,
}) I'm working with typscript 4.8.3, and octokit 3.1.2. |
Indeed it does look like it's the headers option. I don't understand why. As stated in a previous comment, you can use the |
What happened?
When using
octokit.paginate
, Typescript errors saying (I think?) that it does not accept a string as the first input. My understanding based on the docs and @octokit/types code is that this input can be a string, and I have confirmed that the code builds and runs if I ignore this error with// @ts-ignore
. I initially had this same code but usingoctokit.request
instead and did not have the error.Note:
DependabotAlert
is my own custom type that defines the resulting output.What happened: Typescript error when building
What I expect to happen: No Typescript error. Should build and run with
"GET /orgs/{org}/dependabot/alerts"
(or any string) as input.Workaround: Add
// @ts-ignore
above this function call so that Typescript will ignore it and build anyways.Versions
nodejs 16.20.0
octokit 2.0.14
@octokit/types 9.0.0 (as a sub-dependency of octokit)
typescript 5.0.4
Relevant log output
Code of Conduct
The text was updated successfully, but these errors were encountered: