-
Notifications
You must be signed in to change notification settings - Fork 79
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
Conversation
There was a problem hiding this 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?
Co-Authored-By: wolfy1339 <4595477+wolfy1339@users.noreply.github.com>
scripts/generate-types.js
Outdated
@@ -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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)
@gr2m This is ready |
There was a problem hiding this 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!
🎉 This PR is included in version 5.3.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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:
In the
Options
type, replace theT
parameter withany
since it was not defined.