Skip to content

Conversation

@WhatCats
Copy link
Contributor

@WhatCats WhatCats commented Nov 20, 2025

Problem

At the moment methods like GuildMemberManager:fetch that have an optional string parameter are doing a falsy check for if the parameter was omitted. But consider the following typescript code:

const id: string = ""
const member: GuildMember = await guild.members.fetch(id)

According to the typings member should be a GuildMember but its actually a Collection<Snowflake, GuildMember> because the empty string is falsy (this is why we love JS).

My Suggestion

Do more exact undefined/null checks.
(I might not have found every place this is an issue)

@vercel
Copy link

vercel bot commented Nov 20, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
discord-js Skipped Skipped Nov 20, 2025 10:44pm
discord-js-guide Skipped Skipped Nov 20, 2025 10:44pm

@vercel vercel bot temporarily deployed to Preview – discord-js November 20, 2025 22:40 Inactive
@vercel vercel bot temporarily deployed to Preview – discord-js-guide November 20, 2025 22:40 Inactive
@WhatCats WhatCats force-pushed the fix/typing-mismatch branch from 16f28a2 to 847f9d3 Compare November 20, 2025 22:43
@vercel vercel bot temporarily deployed to Preview – discord-js-guide November 20, 2025 22:44 Inactive
@vercel vercel bot temporarily deployed to Preview – discord-js November 20, 2025 22:44 Inactive
@Jiralite Jiralite added this to the discord.js 15.0.0 milestone Nov 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants