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

ButtonComponentData fails type guard field check #9734

Closed
hker9527 opened this issue Jul 24, 2023 · 0 comments · Fixed by #9735
Closed

ButtonComponentData fails type guard field check #9734

hker9527 opened this issue Jul 24, 2023 · 0 comments · Fixed by #9735

Comments

@hker9527
Copy link

Which package is this bug report for?

discord.js

Issue description

When using .type field to check for component type, the result will always include ButtonComponentData as it has no definition of .type which falls back to the base definition of type: ComponentType.

Code sample

import { ButtonComponentData, StringSelectMenuComponentData, UserSelectMenuComponentData } from "discord.js";

type Example1 = (
    | ButtonComponentData
    | StringSelectMenuComponentData
    | UserSelectMenuComponentData
);

type Example2 = (
    | StringSelectMenuComponentData
    | UserSelectMenuComponentData
);

const example1: Example1 = {} as any;
const example2: Example2 = {} as any;

if (example1.type === ComponentType.StringSelect) {
    // Type of example1: ButtonComponentData | StringSelectMenuComponentData
}

if (example2.type === ComponentType.StringSelect) {
    // Type of example2: StringSelectMenuComponentData
}

Versions

  • discord.js 14.11.1
  • Node.js 18.16.0
  • TypeScript 4.9.5

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

@Jiralite Jiralite self-assigned this Jul 24, 2023
@kodiakhq kodiakhq bot closed this as completed in #9735 Aug 11, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants