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

Improve TypeScript Types #60

Merged
merged 13 commits into from
Jul 12, 2019
Merged

Improve TypeScript Types #60

merged 13 commits into from
Jul 12, 2019

Conversation

MunifTanjim
Copy link
Contributor

@MunifTanjim MunifTanjim commented Jul 11, 2019

Example Usage:

// Options type
type O = { [key: string]: any }

// return type
type R = number

const hook = new Singular<O, R>()

const hookMethod = async (options: O): Promise<R> => {
  return 42
}

hook(hookMethod, {})

With these changes, the following type definition here can be expressed as:

  hook: HookSingular<Octokit.HookOptions, Octokit.Response<any>, Octokit.HookError>

Edit: well, first it'll have to be changed to a singular hook ¯_(ツ)_/¯


resolves #61 (typings related issue)

@gr2m
Copy link
Owner

gr2m commented Jul 11, 2019

Hey Munif, thanks a lot for your help with Typescript!

I wonder if we could add a typescript test to make sure we don’t break it in future?

We have setup one like this here: https://github.com/octokit/rest.js/blob/master/test/typescript-validate.ts

@MunifTanjim
Copy link
Contributor Author

@gr2m

We have setup one like this here: https://github.com/octokit/rest.js/blob/master/test/typescript-validate.ts

Of course. I'll add a test file like that with the PR.

@MunifTanjim MunifTanjim changed the title [WIP] Improve TypeScript Types Improve TypeScript Types Jul 11, 2019
@MunifTanjim
Copy link
Contributor Author

@gr2m It's done!

Copy link
Owner

@gr2m gr2m left a comment

Choose a reason for hiding this comment

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

fantastic work 🥇 thank you so much!

Just one question

index.d.ts Show resolved Hide resolved
@gr2m gr2m merged commit e57c123 into gr2m:master Jul 12, 2019
@gr2m
Copy link
Owner

gr2m commented Jul 12, 2019

🎉 This PR is included in version 2.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@gr2m gr2m added the released label Jul 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Question: actually supports chaining?
2 participants