You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This leads to anyone importing discord.js into their project having dom types globally available (such as document, window, HTMLDivElement, ...)
These types are of course false, since most discord.js projects will run in node and not in the browser.
Looking at the comment // DOM types required for undici, it seems to reference the experimental fetch global that was recently added to nodejs.
This fetch global internally uses undici, which is what that comment is likely referencing, since the undici npm package is properly typed out of the box.
I could not find any references to the global fetch in the code from a very brief search, so I'm assuming a bit here - however since you already depend on undici anyway:
using the global fetch would not make much sense. You are using an untyped experimental api that is only available in recent node versions, even though you have that same fetch function already installed as a dependency.
To clarify what difference this one line /// <reference lib="dom" /> makes, here are autocompletion suggestions when importing discord.js vs when not importing it:
As soon as discord.js is imported, typescript/vscode will start suggesting browser-only variables and classes. This makes this issue unavoidable, since it occours in your whole project as soon as you simply import discord.js, which is why I'd argue that this is not low priority.
Relevant: d0c8256 by @favna introduced this issue
[A] [B] Some brief conversation regarding this issue on the discord.js discord server
Code sample
No response
Versions
discord.js v14.11.0
NodeJS v18.16.1
Typescript v5.1.6
Issue priority
Medium (should be fixed soon)
Which partials do you have configured?
Not applicable
Which gateway intents are you subscribing to?
Not applicable
I have tested this issue on a development release
No response
The text was updated successfully, but these errors were encountered:
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 to 2 in 8f4256d
This leads to anyone importing discord.js into their project having dom types globally available (such as
document
,window
,HTMLDivElement
, ...)These types are of course false, since most discord.js projects will run in node and not in the browser.
Looking at the comment
// DOM types required for undici
, it seems to reference the experimentalfetch
global that was recently added to nodejs.This fetch global internally uses
undici
, which is what that comment is likely referencing, since the undici npm package is properly typed out of the box.I could not find any references to the global fetch in the code from a very brief search, so I'm assuming a bit here - however since you already depend on undici anyway:
discord.js/packages/discord.js/package.json
Line 65 in 8f4256d
using the global fetch would not make much sense. You are using an untyped experimental api that is only available in recent node versions, even though you have that same fetch function already installed as a dependency.
To clarify what difference this one line
/// <reference lib="dom" />
makes, here are autocompletion suggestions when importing discord.js vs when not importing it:As soon as discord.js is imported, typescript/vscode will start suggesting browser-only variables and classes. This makes this issue unavoidable, since it occours in your whole project as soon as you simply import discord.js, which is why I'd argue that this is not low priority.
Relevant:
d0c8256 by @favna introduced this issue
[A] [B] Some brief conversation regarding this issue on the discord.js discord server
Code sample
No response
Versions
Issue priority
Medium (should be fixed soon)
Which partials do you have configured?
Not applicable
Which gateway intents are you subscribing to?
Not applicable
I have tested this issue on a development release
No response
The text was updated successfully, but these errors were encountered: