From bfbd62e3e00ab47013f6f4a7a63c29074452de54 Mon Sep 17 00:00:00 2001 From: Synbulat Biishev Date: Fri, 23 Feb 2024 14:54:41 +0300 Subject: [PATCH] types(Builder.from): fix wrong types (#10071) * types(Builder.from): fix wrong types * test: add tests --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- packages/discord.js/typings/index.d.ts | 18 +++++--- packages/discord.js/typings/index.test-d.ts | 48 +++++++++++++++++++-- 2 files changed, 56 insertions(+), 10 deletions(-) diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 0ed374d28fbf..afee4fccd109 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -777,7 +777,9 @@ export class StringSelectMenuBuilder extends BuilderStringSelectMenuComponent { public override setOptions( ...options: RestOrArray ): this; - public static from(other: JSONEncodable | APISelectMenuComponent): StringSelectMenuBuilder; + public static from( + other: JSONEncodable | APIStringSelectComponent, + ): StringSelectMenuBuilder; } export { @@ -789,24 +791,26 @@ export { export class UserSelectMenuBuilder extends BuilderUserSelectMenuComponent { public constructor(data?: Partial); - public static from(other: JSONEncodable | APISelectMenuComponent): UserSelectMenuBuilder; + public static from(other: JSONEncodable | APIUserSelectComponent): UserSelectMenuBuilder; } export class RoleSelectMenuBuilder extends BuilderRoleSelectMenuComponent { public constructor(data?: Partial); - public static from(other: JSONEncodable | APISelectMenuComponent): RoleSelectMenuBuilder; + public static from(other: JSONEncodable | APIRoleSelectComponent): RoleSelectMenuBuilder; } export class MentionableSelectMenuBuilder extends BuilderMentionableSelectMenuComponent { public constructor(data?: Partial); public static from( - other: JSONEncodable | APISelectMenuComponent, + other: JSONEncodable | APIMentionableSelectComponent, ): MentionableSelectMenuBuilder; } export class ChannelSelectMenuBuilder extends BuilderChannelSelectMenuComponent { public constructor(data?: Partial); - public static from(other: JSONEncodable | APISelectMenuComponent): ChannelSelectMenuBuilder; + public static from( + other: JSONEncodable | APIChannelSelectComponent, + ): ChannelSelectMenuBuilder; } export class StringSelectMenuOptionBuilder extends BuildersSelectMenuOption { @@ -817,7 +821,9 @@ export class StringSelectMenuOptionBuilder extends BuildersSelectMenuOption { export class ModalBuilder extends BuildersModal { public constructor(data?: Partial | Partial); - public static from(other: JSONEncodable | APIModalComponent): ModalBuilder; + public static from( + other: JSONEncodable | APIModalInteractionResponseCallbackData, + ): ModalBuilder; } export class TextInputBuilder extends BuilderTextInputComponent { diff --git a/packages/discord.js/typings/index.test-d.ts b/packages/discord.js/typings/index.test-d.ts index 679c9ad69415..f68e12d39f98 100644 --- a/packages/discord.js/typings/index.test-d.ts +++ b/packages/discord.js/typings/index.test-d.ts @@ -27,6 +27,11 @@ import { APIActionRowComponent, APIActionRowComponentTypes, APIStringSelectComponent, + APIUserSelectComponent, + APIRoleSelectComponent, + APIChannelSelectComponent, + APIMentionableSelectComponent, + APIModalInteractionResponseCallbackData, } from 'discord-api-types/v10'; import { ApplicationCommand, @@ -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'; @@ -2245,11 +2258,35 @@ 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); @@ -2257,6 +2294,9 @@ ButtonBuilder.from(buttonData); declare const buttonComp: ButtonComponent; ButtonBuilder.from(buttonComp); +declare const modalData: APIModalInteractionResponseCallbackData; +ModalBuilder.from(modalData); + declare const textInputData: APITextInputComponent; TextInputBuilder.from(textInputData);