Skip to content

Commit

Permalink
types(Builder.from): fix wrong types (#10071)
Browse files Browse the repository at this point in the history
* types(Builder.from): fix wrong types

* test: add tests

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
Syjalo and kodiakhq[bot] committed Feb 23, 2024
1 parent c8bbdb7 commit bfbd62e
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 10 deletions.
18 changes: 12 additions & 6 deletions packages/discord.js/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,9 @@ export class StringSelectMenuBuilder extends BuilderStringSelectMenuComponent {
public override setOptions(
...options: RestOrArray<BuildersSelectMenuOption | SelectMenuComponentOptionData | APISelectMenuOption>
): this;
public static from(other: JSONEncodable<APISelectMenuComponent> | APISelectMenuComponent): StringSelectMenuBuilder;
public static from(
other: JSONEncodable<APIStringSelectComponent> | APIStringSelectComponent,
): StringSelectMenuBuilder;
}

export {
Expand All @@ -789,24 +791,26 @@ export {

export class UserSelectMenuBuilder extends BuilderUserSelectMenuComponent {
public constructor(data?: Partial<UserSelectMenuComponentData | APIUserSelectComponent>);
public static from(other: JSONEncodable<APISelectMenuComponent> | APISelectMenuComponent): UserSelectMenuBuilder;
public static from(other: JSONEncodable<APIUserSelectComponent> | APIUserSelectComponent): UserSelectMenuBuilder;
}

export class RoleSelectMenuBuilder extends BuilderRoleSelectMenuComponent {
public constructor(data?: Partial<RoleSelectMenuComponentData | APIRoleSelectComponent>);
public static from(other: JSONEncodable<APISelectMenuComponent> | APISelectMenuComponent): RoleSelectMenuBuilder;
public static from(other: JSONEncodable<APIRoleSelectComponent> | APIRoleSelectComponent): RoleSelectMenuBuilder;
}

export class MentionableSelectMenuBuilder extends BuilderMentionableSelectMenuComponent {
public constructor(data?: Partial<MentionableSelectMenuComponentData | APIMentionableSelectComponent>);
public static from(
other: JSONEncodable<APISelectMenuComponent> | APISelectMenuComponent,
other: JSONEncodable<APIMentionableSelectComponent> | APIMentionableSelectComponent,
): MentionableSelectMenuBuilder;
}

export class ChannelSelectMenuBuilder extends BuilderChannelSelectMenuComponent {
public constructor(data?: Partial<ChannelSelectMenuComponentData | APIChannelSelectComponent>);
public static from(other: JSONEncodable<APISelectMenuComponent> | APISelectMenuComponent): ChannelSelectMenuBuilder;
public static from(
other: JSONEncodable<APIChannelSelectComponent> | APIChannelSelectComponent,
): ChannelSelectMenuBuilder;
}

export class StringSelectMenuOptionBuilder extends BuildersSelectMenuOption {
Expand All @@ -817,7 +821,9 @@ export class StringSelectMenuOptionBuilder extends BuildersSelectMenuOption {

export class ModalBuilder extends BuildersModal {
public constructor(data?: Partial<ModalComponentData> | Partial<APIModalInteractionResponseCallbackData>);
public static from(other: JSONEncodable<APIModalComponent> | APIModalComponent): ModalBuilder;
public static from(
other: JSONEncodable<APIModalInteractionResponseCallbackData> | APIModalInteractionResponseCallbackData,
): ModalBuilder;
}

export class TextInputBuilder extends BuilderTextInputComponent {
Expand Down
48 changes: 44 additions & 4 deletions packages/discord.js/typings/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ import {
APIActionRowComponent,
APIActionRowComponentTypes,
APIStringSelectComponent,
APIUserSelectComponent,
APIRoleSelectComponent,
APIChannelSelectComponent,
APIMentionableSelectComponent,
APIModalInteractionResponseCallbackData,
} from 'discord-api-types/v10';
import {
ApplicationCommand,
Expand Down Expand Up @@ -190,6 +195,14 @@ import {
DirectoryChannel,
Entitlement,
SKU,
UserSelectMenuBuilder,
RoleSelectMenuBuilder,
ChannelSelectMenuBuilder,
MentionableSelectMenuBuilder,
UserSelectMenuComponent,
RoleSelectMenuComponent,
ChannelSelectMenuComponent,
MentionableSelectMenuComponent,
} from '.';
import { expectAssignable, expectNotAssignable, expectNotType, expectType } from 'tsd';
import type { ContextMenuCommandBuilder, SlashCommandBuilder } from '@discordjs/builders';
Expand Down Expand Up @@ -2245,18 +2258,45 @@ chatInputInteraction.showModal({
],
});

declare const selectMenuData: APISelectMenuComponent;
StringSelectMenuBuilder.from(selectMenuData);
declare const stringSelectMenuData: APIStringSelectComponent;
StringSelectMenuBuilder.from(stringSelectMenuData);

declare const selectMenuComp: SelectMenuComponent;
StringSelectMenuBuilder.from(selectMenuComp);
declare const userSelectMenuData: APIUserSelectComponent;
UserSelectMenuBuilder.from(userSelectMenuData);

declare const roleSelectMenuData: APIRoleSelectComponent;
RoleSelectMenuBuilder.from(roleSelectMenuData);

declare const channelSelectMenuData: APIChannelSelectComponent;
ChannelSelectMenuBuilder.from(channelSelectMenuData);

declare const mentionableSelectMenuData: APIMentionableSelectComponent;
MentionableSelectMenuBuilder.from(mentionableSelectMenuData);

declare const stringSelectMenuComp: StringSelectMenuComponent;
StringSelectMenuBuilder.from(stringSelectMenuComp);

declare const userSelectMenuComp: UserSelectMenuComponent;
UserSelectMenuBuilder.from(userSelectMenuComp);

declare const roleSelectMenuComp: RoleSelectMenuComponent;
RoleSelectMenuBuilder.from(roleSelectMenuComp);

declare const channelSelectMenuComp: ChannelSelectMenuComponent;
ChannelSelectMenuBuilder.from(channelSelectMenuComp);

declare const mentionableSelectMenuComp: MentionableSelectMenuComponent;
MentionableSelectMenuBuilder.from(mentionableSelectMenuComp);

declare const buttonData: APIButtonComponent;
ButtonBuilder.from(buttonData);

declare const buttonComp: ButtonComponent;
ButtonBuilder.from(buttonComp);

declare const modalData: APIModalInteractionResponseCallbackData;
ModalBuilder.from(modalData);

declare const textInputData: APITextInputComponent;
TextInputBuilder.from(textInputData);

Expand Down

0 comments on commit bfbd62e

Please sign in to comment.