Skip to content

Commit a8321d8

Browse files
types: fix component *Data types (#7536)
1 parent 1a14c0c commit a8321d8

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

packages/discord.js/typings/index.d.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,11 @@ export interface ActionRowData extends BaseComponentData {
204204
}
205205

206206
export class ActionRow<T extends ActionRowComponent = ActionRowComponent> extends BuilderActionRow<T> {
207-
constructor(data?: ActionRowData | APIActionRowComponent<APIMessageComponent>);
207+
constructor(
208+
data?:
209+
| ActionRowData
210+
| (Omit<APIActionRowComponent<APIMessageComponent>, 'type'> & { type?: ComponentType.ActionRow }),
211+
);
208212
}
209213

210214
export class ActivityFlagsBitField extends BitField<ActivityFlagsString> {
@@ -473,11 +477,13 @@ export class ButtonInteraction<Cached extends CacheType = CacheType> extends Mes
473477
}
474478

475479
export class ButtonComponent extends BuilderButtonComponent {
476-
public constructor(data?: ButtonComponentData | APIButtonComponent);
480+
public constructor(data?: ButtonComponentData | (Omit<APIButtonComponent, 'type'> & { type?: ComponentType.Button }));
477481
}
478482

479483
export class SelectMenuComponent extends BuilderSelectMenuComponent {
480-
public constructor(data?: SelectMenuComponentData | APISelectMenuComponent);
484+
public constructor(
485+
data?: SelectMenuComponentData | (Omit<APISelectMenuComponent, 'type'> & { type?: ComponentType.SelectMenu }),
486+
);
481487
}
482488

483489
export interface EmbedData {
@@ -4619,7 +4625,7 @@ export interface MessageReference {
46194625
export type MessageResolvable = Message | Snowflake;
46204626

46214627
export interface SelectMenuComponentData extends BaseComponentData {
4622-
customId?: string;
4628+
customId: string;
46234629
disabled?: boolean;
46244630
maxValues?: number;
46254631
minValues?: number;

packages/discord.js/typings/index.test-d.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ import {
103103
ShardEvents,
104104
Status,
105105
CategoryChannelChildManager,
106+
ActionRowData,
106107
} from '.';
107108
import { expectAssignable, expectDeprecated, expectNotAssignable, expectNotType, expectType } from 'tsd';
108109
import { Embed } from '@discordjs/builders';
@@ -1309,6 +1310,23 @@ new ActionRow({
13091310
components: [selectMenu.toJSON(), button.toJSON()],
13101311
});
13111312

1313+
new SelectMenuComponent({
1314+
customId: 'foo',
1315+
});
1316+
1317+
new ButtonComponent({
1318+
style: ButtonStyle.Danger,
1319+
});
1320+
1321+
expectNotAssignable<ActionRowData>({
1322+
type: ComponentType.ActionRow,
1323+
components: [
1324+
{
1325+
type: ComponentType.Button,
1326+
},
1327+
],
1328+
});
1329+
13121330
declare const chatInputInteraction: ChatInputCommandInteraction;
13131331

13141332
expectType<MessageAttachment>(chatInputInteraction.options.getAttachment('attachment', true));

0 commit comments

Comments
 (0)