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(typescript): Fix errors from linters and an update for signatures #58

Merged
merged 6 commits into from
Jan 31, 2019

Conversation

wolfy1339
Copy link
Member

You can't use ESModule and CommonJS exports in the same file (you could theoretically, but it's bad practice), so we have to move the definitions into the namespace.

This does not affect the way to import the types, you can still do this:

import { WebhookPayloadStatus } from '@octokit/webhooks';

In the Options type, replace the T parameter with any since it was not defined.

Copy link
Contributor

@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.

could you run npm run generate-types to also update the index.d.ts file?

scripts/generate-types.js Outdated Show resolved Hide resolved
Co-Authored-By: wolfy1339 <4595477+wolfy1339@users.noreply.github.com>
@@ -24,7 +24,8 @@ webhooks.forEach(({ name, actions, examples }) => {
...actions.map(action => `'${name}.${action}'`)
].join(' | ')
signatures.push(`
public on (event: ${events}, callback: (event: Webhooks.WebhookEvent<${typeName}>) => void): void
public on (event: ${events}, callback: (event: Webhooks.WebhookEvent<Webhooks.${typeName}>) => void): void
public on (event: ${events}, callback: (event: Webhooks.WebhookEvent<Webhooks.${typeName}>) => Promise<void>): void
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder, can you combine the two lines above?

public on (event: ${events}, callback: (event: Webhooks.WebhookEvent<Webhooks.${typeName}>) => void | Promise<void>): void

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure if It could work, I'll go test

The option argument is not required in the Webhooks class constructor.
A `declare` modifier is needed for top-level declarations in a `.d.ts` file (TS1046)
@wolfy1339
Copy link
Member Author

@gr2m This is ready

Copy link
Contributor

@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.

Thanks for the ping!

@gr2m gr2m merged commit d7a1757 into octokit:master Jan 31, 2019
@octokitbot
Copy link
Collaborator

🎉 This PR is included in version 5.3.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants