Skip to content
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

Inaccurate typings for GuildMember#partial #10293

Open
TAEMBO opened this issue May 20, 2024 · 0 comments
Open

Inaccurate typings for GuildMember#partial #10293

TAEMBO opened this issue May 20, 2024 · 0 comments

Comments

@TAEMBO
Copy link
Contributor

TAEMBO commented May 20, 2024

Which package is this bug report for?

discord.js

Issue description

This is a continuation of this discussion.
As a refresher from the above, the discord.js GuildMember structure comes with a partial property whose definition states whether GuildMember#joinedTimestamp is null or not. When using this in a TypeScript project, the type definition for GuildMember#partial is strictly false. With that, one can infer from this that GuildMember#joinedTimestamp surely won't ever be null then, yet the typings for that property say otherwise. These typings contradict each other on whether GuildMember#joinedTimestamp is actually nullish or not.

Jiralite in the discussion linked above made mention that "Receiving a PRESENCE_UPDATE event on an uncached guild member has no joined_at field". What would prevent the further use of the PartialGuildMember type, which appropriately nullifies appropriate property types and informs the developer that the structure is a partial? Using this type where applicable would then negate the need to have nullish joinedTimestamp and joinedAt property value types for the GuildMember structure, which would then bring these aforementioned GuildMember property types into harmony.

Reproduce steps
1: Create new discord.js project with TypeScript
2: Import GuildMember and PartialGuildMember types
3: Observe property values partial, joinedAt, and joinedTimestamp on both types

Code sample

import type { GuildMember, PartialGuildMember } from "discord.js";

declare const guildMember: GuildMember;
declare const partialGuildMember: PartialGuildMember;

guildMember.joinedTimestamp; // number | null
guildMember.partial; // false
partialGuildMember.joinedTimestamp; // null
partialGuildMember.partial; // true

Versions

  • discord.js v14.15.2
  • Node.js v18.17.0
  • Typescript v5.4.5
  • Windows 10 Home 22H2 19045.4412

Issue priority

Low (slightly annoying)

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants