mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-19 21:13:30 +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>
|
| APIActionRowComponent<APIMessageActionRowComponent | APIModalActionRowComponent>
|
||||||
>,
|
>,
|
||||||
);
|
);
|
||||||
public static from(
|
public static from<T extends AnyComponentBuilder = AnyComponentBuilder>(
|
||||||
other:
|
other:
|
||||||
| JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent | APIModalActionRowComponent>>
|
| JSONEncodable<APIActionRowComponent<ReturnType<T['toJSON']>>>
|
||||||
| APIActionRowComponent<APIMessageActionRowComponent | APIModalActionRowComponent>,
|
| APIActionRowComponent<ReturnType<T['toJSON']>>,
|
||||||
): ActionRowBuilder;
|
): ActionRowBuilder<T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type MessageActionRowComponent =
|
export type MessageActionRowComponent =
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ import {
|
|||||||
APIEmbed,
|
APIEmbed,
|
||||||
ApplicationCommandType,
|
ApplicationCommandType,
|
||||||
APIMessage,
|
APIMessage,
|
||||||
|
APIActionRowComponent,
|
||||||
|
APIActionRowComponentTypes,
|
||||||
APIStringSelectComponent,
|
APIStringSelectComponent,
|
||||||
} from 'discord-api-types/v10';
|
} from 'discord-api-types/v10';
|
||||||
import {
|
import {
|
||||||
@@ -134,6 +136,8 @@ import {
|
|||||||
Webhook,
|
Webhook,
|
||||||
WebhookClient,
|
WebhookClient,
|
||||||
InteractionWebhook,
|
InteractionWebhook,
|
||||||
|
ActionRowComponent,
|
||||||
|
ActionRow,
|
||||||
GuildAuditLogsActionType,
|
GuildAuditLogsActionType,
|
||||||
GuildAuditLogsTargetType,
|
GuildAuditLogsTargetType,
|
||||||
ModalSubmitInteraction,
|
ModalSubmitInteraction,
|
||||||
@@ -2046,6 +2050,24 @@ EmbedBuilder.from(embedData);
|
|||||||
declare const embedComp: Embed;
|
declare const embedComp: Embed;
|
||||||
EmbedBuilder.from(embedComp);
|
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 stageChannel: StageChannel;
|
||||||
declare const partialGroupDMChannel: PartialGroupDMChannel;
|
declare const partialGroupDMChannel: PartialGroupDMChannel;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user