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:
TÆMBØ 2024-05-15 10:36:02 -07:00 committed by GitHub
parent c2432d5704
commit 29fd89f23c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 32 additions and 0 deletions

View 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>();

View file

@ -27,6 +27,17 @@ export class SharedSlashCommand {
public readonly options: ToAPIApplicationCommandOptions[] = [];
/**
* @deprecated Use {@link SharedSlashCommand.setDefaultMemberPermissions} or {@link SharedSlashCommand.setDMPermission} instead.
*/
public readonly default_permission: boolean | undefined = undefined;
public readonly default_member_permissions: Permissions | null | undefined = undefined;
public readonly dm_permission: boolean | undefined = undefined;
public readonly nsfw: boolean | undefined = undefined;
/**
* Sets whether the command is enabled by default when the application is added to a guild.
*

View file

@ -4,6 +4,10 @@ export default defineConfig({
test: {
exclude: ['**/node_modules', '**/dist', '.idea', '.git', '.cache'],
passWithNoTests: true,
typecheck: {
enabled: true,
include: ["**/__tests__/types.test.ts"]
},
coverage: {
enabled: true,
all: true,