mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
types: add generic to ActionRowBuilder.from() (#8414)
* types: add generic to `ActionRowBuilder#from()` * test: add tests for `ActionRowBuilder.from()` * tests: add more tests
This commit is contained in:
8
packages/discord.js/typings/index.d.ts
vendored
8
packages/discord.js/typings/index.d.ts
vendored
@@ -288,11 +288,11 @@ export class ActionRowBuilder<T extends AnyComponentBuilder = AnyComponentBuilde
|
||||
| APIActionRowComponent<APIMessageActionRowComponent | APIModalActionRowComponent>
|
||||
>,
|
||||
);
|
||||
public static from(
|
||||
public static from<T extends AnyComponentBuilder = AnyComponentBuilder>(
|
||||
other:
|
||||
| JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent | APIModalActionRowComponent>>
|
||||
| APIActionRowComponent<APIMessageActionRowComponent | APIModalActionRowComponent>,
|
||||
): ActionRowBuilder;
|
||||
| JSONEncodable<APIActionRowComponent<ReturnType<T['toJSON']>>>
|
||||
| APIActionRowComponent<ReturnType<T['toJSON']>>,
|
||||
): ActionRowBuilder<T>;
|
||||
}
|
||||
|
||||
export type MessageActionRowComponent =
|
||||
|
||||
@@ -24,6 +24,8 @@ import {
|
||||
APIEmbed,
|
||||
ApplicationCommandType,
|
||||
APIMessage,
|
||||
APIActionRowComponent,
|
||||
APIActionRowComponentTypes,
|
||||
APIStringSelectComponent,
|
||||
} from 'discord-api-types/v10';
|
||||
import {
|
||||
@@ -134,6 +136,8 @@ import {
|
||||
Webhook,
|
||||
WebhookClient,
|
||||
InteractionWebhook,
|
||||
ActionRowComponent,
|
||||
ActionRow,
|
||||
GuildAuditLogsActionType,
|
||||
GuildAuditLogsTargetType,
|
||||
ModalSubmitInteraction,
|
||||
@@ -2046,6 +2050,24 @@ EmbedBuilder.from(embedData);
|
||||
declare const embedComp: Embed;
|
||||
EmbedBuilder.from(embedComp);
|
||||
|
||||
declare const actionRowData: APIActionRowComponent<APIActionRowComponentTypes>;
|
||||
ActionRowBuilder.from(actionRowData);
|
||||
|
||||
declare const actionRowComp: ActionRow<ActionRowComponent>;
|
||||
ActionRowBuilder.from(actionRowComp);
|
||||
|
||||
declare const buttonsActionRowData: APIActionRowComponent<APIButtonComponent>;
|
||||
declare const buttonsActionRowComp: ActionRow<ButtonComponent>;
|
||||
|
||||
expectType<ActionRowBuilder<ButtonBuilder>>(ActionRowBuilder.from<ButtonBuilder>(buttonsActionRowData));
|
||||
expectType<ActionRowBuilder<ButtonBuilder>>(ActionRowBuilder.from<ButtonBuilder>(buttonsActionRowComp));
|
||||
|
||||
declare const anyComponentsActionRowData: APIActionRowComponent<APIActionRowComponentTypes>;
|
||||
declare const anyComponentsActionRowComp: ActionRow<ActionRowComponent>;
|
||||
|
||||
expectType<ActionRowBuilder>(ActionRowBuilder.from(anyComponentsActionRowData));
|
||||
expectType<ActionRowBuilder>(ActionRowBuilder.from(anyComponentsActionRowComp));
|
||||
|
||||
declare const stageChannel: StageChannel;
|
||||
declare const partialGroupDMChannel: PartialGroupDMChannel;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user