Don't include lib.dom.d.ts

Apparently discord.js includes lib.dom.d.ts types. This pollutes the user's type namespace with dom types by just including discord.js, making typescript think that things like document will be available (when they of course wont be, since discord.js will always always run in nodejs). From what I can find, there's no real way to exclude dom types from userland if they have been included in a library. A library should not include dom types unless it uses things that are only available in the dom (in which case it probably wont run in node). I couldn't find any discussion about this, neither here nor in github issues, but this is really bad practice from what I know? If undici for whatever reason requires dom types even though it is explicitly made for node, then it is a bad package and should be fixed instead of polluting the users types.
6 Replies
d.js toolkit
d.js toolkit17mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Temm
TemmOP17mo ago
-- [email protected] Node v18.16.1 The rest is N/A since this is a type issue.
Temm
TemmOP17mo ago
Temm
TemmOP17mo ago
Temm
TemmOP17mo ago
so you include all dom types globally so you can have types for the experimental undici fetch api even though you have undici explicitly installed anyway? are you using the fetch global somewhere despite having undici installed anyway or why? i can only find files that explicitly include fetch from undici ty for convo link tho
Temm
TemmOP17mo ago
Closing this in favor of the issue I created regarding this https://github.com/discordjs/discord.js/issues/9737
GitHub
Don't include dom types · Issue #9737 · discordjs/discord.js
Which package is this bug report for? discord.js Issue description discord.js currently includes the dom types lib in its main types.d.ts discord.js/packages/discord.js/typings/index.d.ts Lines 1 t...
Want results from more Discord servers?
Add your server