Skip to content
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

fix(RequestInterface): restore catch all overload #404

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/RequestInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@ export interface RequestInterface<D extends object = object> {
* @param {string} route Request method + URL. Example: `'GET /orgs/{org}'`
* @param {object} [parameters] URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`.
*/
(route: Route, options?: RequestParameters): Promise<OctokitResponse<any>>;
<R extends Route>(
route: keyof Endpoints | R,
options?: R extends keyof Endpoints
? Endpoints[R]["parameters"] & RequestParameters
: RequestParameters
): R extends keyof Endpoints
? Promise<Endpoints[R]["response"]>
: Promise<OctokitResponse<any>>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a full revert of the changes at https://github.com/octokit/types.ts/pull/399/files, is that on purpose?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that's on purpose. The first overload fixes routes autocompletion in TS 4.7, but we still need the old one for options autocomplete to work properly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We reverted #399 via #405 because it had some more unforeseen consequences. I'd prefer we would figure out what broke with TS 4.7 and help the team to fix the problem on their side


/**
* Returns a new `request` with updated route and parameters
Expand Down