Skip to content

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