Skip to content

GuildMember.nickname has incorrect typings #4640

@octylFractal

Description

@octylFractal

Please describe the problem you are having in as much detail as possible:
I am trying to avoid saving a nickname if it is not set, but the typings incorrectly claim string | null when it is actually string | undefined.

Include a reproducible code sample here, if possible:

    const nickname = member.nickname;
    if (nickname !== null) {
        console.log(memTag, 'Saving name:', nickname);
        setUserName(member.user.id, member.guild.id, nickname);
    }

This code will log "Saving name: undefined" when someone has no nickname, rather than not logging a message at all.

Further details:

  • discord.js version: 12.2.0
  • Node.js version: 14.1.0
  • Operating system: Linux
  • Priority this issue should have – please be realistic and elaborate if possible: High priority, causes unexpected bugs due to undeclared branch possibilities that the compiler cannot know
  • I have also tested the issue on latest master, commit hash: f9f3661

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions