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

Conversation

levenleven
Copy link
Contributor

Description

#399 fixed routes autocompletion, but request options resolution was broken as a result. TypeScript selected second non generic overload once {} was provided as the options parameter.

This PR restores previous generic version which accepts both known/predefined and dynamic routes (in addition to overload that accepts only known routes), so TS will always try to resolve request options type according to provided route.


Closes octokit/core.js#486

** Maybe it worth opening issue in TypeScript and try to understand why existing solution stopped working since 4.7

: 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

@wolfy1339 wolfy1339 added the Type: Bug Something isn't working as documented, or is being fixed label Jul 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working as documented, or is being fixed
Projects
Status: 🔥 Backlog
Development

Successfully merging this pull request may close these issues.

[Typescript] request options autocomplete not working
4 participants