#Builders 1.10.1 > 1.11.x causes errors

1 messages · Page 1 of 1 (latest)

woeful lily

I'm by no means a TS wizard, but I try.

In one of my apps, I create a clear button that I pass around and is made available throughout the code. It's effectively a button that when hit, will delete/'close' the message it's attached to.

I create it in my interactionCreate listener like this:

const clear = new ActionRowBuilder<ButtonBuilder>().addComponents([new ButtonBuilder().setCustomId('botMessageClose').setLabel('❌ Close').setStyle(ButtonStyle.Success)]);

I've been doing it this way for a long time without issue.

Today, whilst having an unrelated issue with zlib-sync not installing on my MacBook, I tried to troubleshoot and in the process, I deleted node_modules and the package-lock file. The issue didn't resolve, but as a side effect, it meant the builders dependency for discord.js got bumped from 1.10.1 to 1.11.0 (and then 1.11.1 a short while ago).

This immediately flooded my app with errors, 172 specifically. Looking at it closer I see that every single one of them related to an issue with ActionRowBuilder<ButtonBuilder> no longer satisfying the type requirements for the components array of a message/interaction response.

Downgrading the dependency back to 1.10.1 removed all the errors immediately.

I'd rather be up to date, so I have no issue with 'fixing' my code to accommodate whatever specific type changes were made, but I struggle to see what was changed to cause the error, given how the existing components are fundamentally unchanged.

This is the error I get when using 1.11. with my above code:

Type 'ActionRowBuilder<ButtonBuilder>[]' is not assignable to type 'readonly (APIActionRowComponent<APIMessageActionRowComponent> | JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent>> | ActionRowData<...>)[]'.
  Type 'ActionRowBuilder<ButtonBuilder>' is not assignable to type 'APIActionRowComponent<APIMessageActionRowComponent> | JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent>> | ActionRowData<...>'.
    Property 'type' is missing in type 'ActionRowBuilder<ButtonBuilder>' but required in type 'ActionRowData<MessageActionRowComponentData | MessageActionRowComponentBuilder>'.ts(2322)
index.d.mts(301, 3): 'type' is declared here.
(property) components?: readonly (APIActionRowComponent<APIMessageActionRowComponent> | JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent>> | ActionRowData<...>)[]

Any input or advice would be greatly appreciated.