discord.js
discord.js copied to clipboard
types: overriding `events.once` type causes bad intellisense autocompletion elsewhere
Which package is this bug report for?
discord.js
Issue description

Code sample
import { once } from 'events'
import { createServer } from 'http'
import { request } from 'undici'
const server = createServer(async (req, res) => {
req.setEncoding('utf-8')
for await (const chunk of req) console.log(chunk)
res.end()
}).listen(0)
await once(server, '') // <-----
// @ts-ignore
await request(`http://localhost:${server.address().port}`, {
body: new Uint8Array([65, 66, 67, 68])
})
server.close()
Package version
14.3.0
Node.js version
18.9.0
Operating system
n/a
Priority this issue should have
Low (slightly annoying)
Which partials do you have configured?
Not applicable (subpackage bug)
Which gateway intents are you subscribing to?
Not applicable (subpackage bug)
I have tested this issue on a development release
No response
https://github.com/discordjs/discord.js/pull/7986#discussion_r886333659
It has no effect on the event emitter types for anything else
@suneettipirneni this seems like a bug as it shouldn't affect other, non-djs things?
or is it because both node's http server and discord.js Client extend EventEmitter?
or is it because both node's http server and discord.js Client extend EventEmitter?
yeah because the type in djs is adding an overload to the node:events so you'll see all these event names + any other overload if exists + any string
yeah because the type in djs is adding an overload to the node:events so you'll see all these event names + any other overload if exists + any string
I'm not entirely sure why this is the case since I expect overloads to match based on parameter type. Nonetheless I suppose this would need to be reverted.