Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

types(Builder.from): fix wrong types #10071

Merged
merged 3 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading