[TypeScript] - The VS Code alert a ghost error when i inset a ActionRow in message components array

Firstly, the code:
const button = new ButtonBuilder()
.setCustomId("test")
.setStyle(ButtonStyle.Success)
.setLabel("Test")

const row = new ActionRowBuilder().addComponents([button]);

await int.reply({ components: [row] });
const button = new ButtonBuilder()
.setCustomId("test")
.setStyle(ButtonStyle.Success)
.setLabel("Test")

const row = new ActionRowBuilder().addComponents([button]);

await int.reply({ components: [row] });
Well... I'm making a bot with Typescript, but even when i insert a actionrow in the components array the vs code show me this error:
Type 'ActionRowBuilder<AnyComponentBuilder>' cannot be assigned to type 'APIActionRowComponent<APIMessageActionRowComponent> | JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent>> | ActionRowData<...>'.
The 'type' property is absent in type 'ActionRowBuilder<AnyComponentBuilder>', but is required in type 'ActionRowData<MessageActionRowComponentData | MessageActionRowComponentBuilder>'.ts(2322)
Type 'ActionRowBuilder<AnyComponentBuilder>' cannot be assigned to type 'APIActionRowComponent<APIMessageActionRowComponent> | JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent>> | ActionRowData<...>'.
The 'type' property is absent in type 'ActionRowBuilder<AnyComponentBuilder>', but is required in type 'ActionRowData<MessageActionRowComponentData | MessageActionRowComponentBuilder>'.ts(2322)
The command run without problems, but i get this error in vs code... How can i solve this? (Whitout using @ts-ignore. please) discord.js version: 14.11.0 node.js version: 18.3.0
4 Replies
d.js toolkit
d.js toolkit13mo ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
d.js docs
d.js docs13mo ago
Tag suggestion for @cleiton2040: In TypeScript the ActionRowBuilder class has a generic type parameter that specifies the type of component the action row holds:
const row = new ActionRowBuilder<ButtonBuilder>().addComponents(button)
const row = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(selectMenu)
const row = new ActionRowBuilder<TextInputBuilder>().addComponents(textInput)
const row = new ActionRowBuilder<ButtonBuilder>().addComponents(button)
const row = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(selectMenu)
const row = new ActionRowBuilder<TextInputBuilder>().addComponents(textInput)
José
José13mo ago
Ow yes, this solved my problem, thanks
Danial
Danial13mo ago
Of course