discordjs / discord.js

A powerful JavaScript library for interacting with the Discord API
https://discord.js.org
Apache License 2.0
25.14k stars 3.95k forks source link

`ActionRowBuilder<T>` does not enforce the type of the components to be `T` in the constructor #10259

Open Ptitet opened 2 months ago

Ptitet commented 2 months ago

Which package is this bug report for?

builders

Issue description

When building an ActionRow with ActionRowBuilder, the type parameter passed does not seem to enforce the components to be of the type passed. I tested it in VSCode and got no error from IntelliSense : image

Code sample

const actionRow = new ActionRowBuilder<StringSelectMenuBuilder>({
    components: [
        new ButtonBuilder({/* ... */}); // no error from IntelliSense
    ]
});

Versions

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

monbrey commented 2 months ago

This behaviour only applies to the constructor, which is inherited. We may still be able to address it though.

If you require a solution before a fix is applied, the .addComponents method is type-safe:

image