-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Octokit: Try upgrading to v19 #29043
base: trunk
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot help with the JSDoc errors I'm afraid.
2c4459f
to
fa8f34a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kinda seems like inferring types might be the most reasonable option here? 😬
Re: JSDoc, might just need to /* eslint-disable jsdoc/valid-types */
🤷 Pending improved support.
Can't recall what all repercussions might be involved, but wonder if it might be worth giving up on jsdoc/valid-types
altogether and disable it project-wide.
bin/plugin/lib/milestone.js
Outdated
@@ -14,18 +20,13 @@ | |||
* @param {string} repo Repository name. | |||
* @param {string} title Milestone title. | |||
* | |||
* @return {Promise<OktokitIssuesListMilestonesForRepoResponseItem|void>} Promise resolving to milestone, if exists. | |||
* @return {Promise<listMilestonesResponse["data"]|undefined>} Promise resolving to milestone, if exists. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should only be a single value returned from this, hence an error about mismatched types on how listMilestonesResponse["data"]
is an array. I guess an alternative could be to pull in the type for the singular item response?
/** @typedef {Endpoints["GET /repos/{owner}/{repo}/milestones/{milestone_number}"]["response"]} getMilestoneResponse */
Then:
* @return {Promise<listMilestonesResponse["data"]|undefined>} Promise resolving to milestone, if exists. | |
* @return {Promise<getMilestoneResponse["data"]|undefined>} Promise resolving to milestone, if exists. |
Or, reference the base types schema:
/** @typedef {import('@octokit/openapi-types').components["schemas"]["milestone"]} Milestone */
Or maybe it's not worth documenting it, and just letting the inferred type go through 🤷
* @return {Promise<listMilestonesResponse["data"]|undefined>} Promise resolving to milestone, if exists. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should only be a single value returned from this, hence an error about mismatched types on how
listMilestonesResponse["data"]
is an array.
Thanks! I got a bit caught up in the JSDoc syntax error and missed that this one was actually (also) a TS problem.
Thanks for your suggested fixes! I think I'll go with the Milestone
(from @octokit/openapi-types
, which I was unaware of), since it's the most semantic option.
Or maybe it's not worth documenting it, and just letting the inferred type go through 🤷
I seem to be getting any
in that case though 🤔 (looking at the call site in changelog.js
).
fa8f34a
to
fbc31a9
Compare
Hey @aduth, thanks for dropping by! 😄
Going with explicit for now -- I felt like I should provide a
Yeah, I was hoping to avoid that, but looks like a reasonable trade-off 👍
Indeed, might be worth considering 🤔 |
bin/plugin/lib/milestone.js
Outdated
@@ -59,7 +58,7 @@ async function getIssuesByMilestone( | |||
state, | |||
closedSince | |||
) { | |||
const options = octokit.issues.listForRepo.endpoint.merge( { | |||
const responses = octokit.paginate.iterator( octokit.issues.listForRepo, { | |||
owner, | |||
repo, | |||
milestone, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like TS is complaining since it expects a string | undefined
here -- but the docs say that a number should be okay 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would indeed fix the issue, but I think we might want to report this upstream instead:
diff --git a/bin/plugin/lib/milestone.js b/bin/plugin/lib/milestone.js
index 226d968980..7fe20cfeee 100644
--- a/bin/plugin/lib/milestone.js
+++ b/bin/plugin/lib/milestone.js
@@ -43,7 +43,7 @@ async function getMilestoneByTitle( octokit, owner, repo, title ) {
* @param {GitHub} octokit Initialized Octokit REST client.
* @param {string} owner Repository owner.
* @param {string} repo Repository name.
- * @param {number} milestone Milestone ID.
+ * @param {string} milestone Milestone ID.
* @param {IssueState} [state] Optional issue state.
* @param {string} [closedSince] Optional timestamp.
*
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we might want to report this upstream instead
This is indeed a bug in GitHub's OpenAPI spec, from which all the @octokit types and method names are generated:
- name: milestone
description: If an `integer` is passed, it should refer to a milestone by
its `number` field. If the string `*` is passed, issues with any milestone
are accepted. If the string `none` is passed, issues without milestones
are returned.
in: query
required: false
schema:
type: string
I filed an issue here: github/rest-api-description#226
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, beat me to it! Thanks a lot @gr2m!
5eef3d5
to
e2d11f4
Compare
Description
Spurred by #28424 (comment).
Currently based on #28424; might change that later, or rebase once #28424 has landed.
The Octokit API has changed drastically since v16.*, with most types now being auto-generated from GH's REST API docs, and made available through helpers that basically accept REST API routes as parameters, as described at https://github.com/octokit/types.ts/tree/63fd0dcd31c1a547170ccdb72e7885a9b4080745#examples, e.g.
Alas, that kind of type doesn't seem to work too well with JSDoc: While it seems that I've managed to get the example into a shape that's accepted by TS, JSDoc throws a number of syntax errors 😕
The alternative (which is based on
octokit
instances) works inside of a context where such an instance is available -- but can't be used where it isn't, e.g. in a function's@return
type declaration.