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
revert: add types to EventEmitter
static methods
#8644
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
Codecov Report
@@ Coverage Diff @@
## main #8644 +/- ##
==========================================
+ Coverage 86.66% 86.68% +0.01%
==========================================
Files 86 87 +1
Lines 8771 8784 +13
Branches 1105 1110 +5
==========================================
+ Hits 7601 7614 +13
Misses 1128 1128
Partials 42 42
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
I don't see why we should revert this 😕 Nevertheless I'm fine with the revert if others are too (but I feel like it's a downgrade in experience for those that do use this) CC @discordjs/the-big-4 for other thoughts. |
No strong opinion (the autocomplete is just wrong & annoying) but this is almost 100% better off left to a utility function or to the users since it has side effects. import events from 'node:events'
import type { Client, ClientEvents } from 'discord.js'
export const once = <K extends keyof ClientEvents>(
eventEmitter: Client,
eventName: K
): Promise<ClientEvents[K]> => events.once(eventEmitter, eventName)
export const on = <K extends keyof ClientEvents>(
eventEmitter: Client,
eventName: K
): AsyncIterableIterator<ClientEvents[K]> => events.on(eventEmitter, eventName) and then used the same declare const client: Client
const [member] = await once(client, 'guildMemberAdd')
for await (const [channel] of on(client, 'channelCreate')) {
// ...
} |
Alternative PR which fixes the issue instead of reverting: #8681 |
Please describe the changes this PR makes and why it should be merged:
Fixes #8634
Reverts #7986
Status and versioning classification: