🚧 [Help Wanted] types for endpoint(options)
#50
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull requests attempts to introduce type validations for
endpoint(options)
. It looks for theoptions.method
andoptions.url
and compares them to known routes. If there is a match, it enforces the required options for that route and returns a better typed result.The problem is that TypeScript throws an error for
EndpointsByUrlAndMethod[O["url"]][O["method"]]["request"]
I don't know if that is resolvable at all. I might have hit a limit of what TypeScript is capable of doing.
The reason I'd like to make this possible is that we would no longer require defining custom type definitions for rest endpoint methods as we do in https://raw.githubusercontent.com/octokit/plugin-rest-endpoint-methods.js/53e3403d39e35b25ac3b5ae872895ab4277067cd/src/generated/types.ts, because all typings would be set correctly by doing sth like this
If anyone is up for a challenge, it's all yours :)