mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 04:23:31 +01:00
fix(SlashCommandBuilder): add missing shared properties (#10255)
* types(SlashCommandBuilder): add missing shared properties * Add tests for types * Fix formatting * Enable Vitest type checking --------- Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
This commit is contained in:
17
packages/builders/__tests__/types.test.ts
Normal file
17
packages/builders/__tests__/types.test.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { expectTypeOf } from 'vitest';
|
||||
import { SlashCommandBuilder, SlashCommandStringOption, SlashCommandSubcommandBuilder } from '../src/index.js';
|
||||
|
||||
const getBuilder = () => new SlashCommandBuilder();
|
||||
const getStringOption = () => new SlashCommandStringOption().setName('owo').setDescription('Testing 123');
|
||||
const getSubcommand = () => new SlashCommandSubcommandBuilder().setName('owo').setDescription('Testing 123');
|
||||
|
||||
type BuilderPropsOnly<Type = SlashCommandBuilder> = Pick<
|
||||
Type,
|
||||
keyof {
|
||||
[Key in keyof Type as Type[Key] extends (...args: any) => any ? never : Key]: any;
|
||||
}
|
||||
>;
|
||||
|
||||
expectTypeOf(getBuilder().addStringOption(getStringOption())).toMatchTypeOf<BuilderPropsOnly>();
|
||||
|
||||
expectTypeOf(getBuilder().addSubcommand(getSubcommand())).toMatchTypeOf<BuilderPropsOnly>();
|
||||
Reference in New Issue
Block a user