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
I've discovered incorrect typings in some of the partial types. Particularly, the .toString() method supposedly always evaluates to "[object Object]", despite this never being the case during runtime.
Why I believe I'm correct:
<GuildMember>.toString() returns a UserMention which is (ultimately) based on <GuildMember>.user.id
<GuildMember>.id returns <GuildMember>.user.id
The id property is guaranteed to exist on all partial types (see Partialize type)
Therefore, <PartialGuildMember>.user.id is also guaranteed to exist
That is to say: PartialGuildMembers are always mentionable
Consequently, <PartialGuildMember>.toString() should always yield a string like the non-partial variant does
During runtime, PartialGuildMember always has a .toString() method attached.
However, typescript-eslint (extending plugin:@typescript-eslint/strict-type-checked) tells me that the latter may evaluate to "[object Object]" (@typescript-eslint/no-base-to-string).
This problem also exists on other partial types. I have yet to look a bit further into this, but so far I've identified this to potentially be the case with User, Channel, MessageReaction and ThreadMember.
Code sample
/* eslint-disable @typescript-eslint/no-unused-vars */import{GuildMember,PartialGuildMember}from"discord.js";// No linting error herefunctiontest1(member: GuildMember){console.log(`${member.toString()}`);}// Throws @typescript-eslint/no-base-to-string with typescript-eslintfunctiontest2(member: PartialGuildMember){console.log(`${member.toString()}`);}
Versions
discord.js 14.13.0
Node.js 18.17.1
TypeScript 5.2.2
Windows 10 Pro N 22H2 Build 19045.3086 with Experience 1000.19041.1000.0
Which package is this bug report for?
discord.js
Issue description
I've discovered incorrect typings in some of the partial types. Particularly, the
.toString()
method supposedly always evaluates to"[object Object]"
, despite this never being the case during runtime.Why I believe I'm correct:
<GuildMember>.toString()
returns aUserMention
which is (ultimately) based on<GuildMember>.user.id
<GuildMember>.id
returns<GuildMember>.user.id
id
property is guaranteed to exist on all partial types (seePartialize
type)<PartialGuildMember>.user.id
is also guaranteed to existPartialGuildMember
s are always mentionable<PartialGuildMember>.toString()
should always yield a string like the non-partial variant doesDuring runtime,
PartialGuildMember
always has a.toString()
method attached.However, typescript-eslint (extending
plugin:@typescript-eslint/strict-type-checked
) tells me that the latter may evaluate to "[object Object]" (@typescript-eslint/no-base-to-string).This problem also exists on other partial types. I have yet to look a bit further into this, but so far I've identified this to potentially be the case with
User
,Channel
,MessageReaction
andThreadMember
.Code sample
Versions
discord.js 14.13.0
Node.js 18.17.1
TypeScript 5.2.2
Windows 10 Pro N 22H2 Build 19045.3086 with Experience 1000.19041.1000.0
eslint 8.48.0
@types/node 18.17.1
@typescript-eslint/eslint-plugin 6.6.0
@typescript-eslint/parser 6.6.0
Issue priority
Low (slightly annoying)
Which partials do you have configured?
GuildMember
Which gateway intents are you subscribing to?
GuildMembers
I have tested this issue on a development release
0d40855.0
The text was updated successfully, but these errors were encountered: