From 73c11b99a4f4a549d0457adb800220246357ed09 Mon Sep 17 00:00:00 2001 From: suneettipirneni Date: Thu, 3 Feb 2022 15:48:06 -0500 Subject: [PATCH 1/2] refactor: remove conditional returns --- ...mmandOptionWithChoicesAndAutocompleteMixin.ts | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/packages/builders/src/interactions/slashCommands/mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin.ts b/packages/builders/src/interactions/slashCommands/mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin.ts index 88169c8de99b..a8fd93c3ecef 100644 --- a/packages/builders/src/interactions/slashCommands/mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin.ts +++ b/packages/builders/src/interactions/slashCommands/mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin.ts @@ -20,7 +20,7 @@ export class ApplicationCommandOptionWithChoicesAndAutocompleteMixin { + public addChoice(name: string, value: T): this { if (this.autocomplete) { throw new RangeError('Autocomplete and choices are mutually exclusive to each other.'); } @@ -51,7 +51,7 @@ export class ApplicationCommandOptionWithChoicesAndAutocompleteMixin { + public addChoices(choices: [name: string, value: T][]): this { if (this.autocomplete) { throw new RangeError('Autocomplete and choices are mutually exclusive to each other.'); } @@ -62,11 +62,7 @@ export class ApplicationCommandOptionWithChoicesAndAutocompleteMixin( - choices: Input, - ): Input extends [] - ? this & Pick, 'setAutocomplete'> - : Omit { + public setChoices(choices: [name: string, value: T][]) { if (choices.length > 0 && this.autocomplete) { throw new RangeError('Autocomplete and choices are mutually exclusive to each other.'); } @@ -83,11 +79,7 @@ export class ApplicationCommandOptionWithChoicesAndAutocompleteMixin( - autocomplete: U, - ): U extends true - ? Omit - : this & Pick, 'addChoice' | 'addChoices'> { + public setAutocomplete(autocomplete: boolean) { // Assert that you actually passed a boolean booleanPredicate.parse(autocomplete); From d12addd03c7cf6449aba7caac6e18769bb649766 Mon Sep 17 00:00:00 2001 From: Suneet Tipirneni <77477100+suneettipirneni@users.noreply.github.com> Date: Sat, 5 Feb 2022 17:24:53 -0500 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Almeida --- ...ApplicationCommandOptionWithChoicesAndAutocompleteMixin.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/builders/src/interactions/slashCommands/mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin.ts b/packages/builders/src/interactions/slashCommands/mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin.ts index a8fd93c3ecef..786196fe6235 100644 --- a/packages/builders/src/interactions/slashCommands/mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin.ts +++ b/packages/builders/src/interactions/slashCommands/mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin.ts @@ -62,7 +62,7 @@ export class ApplicationCommandOptionWithChoicesAndAutocompleteMixin 0 && this.autocomplete) { throw new RangeError('Autocomplete and choices are mutually exclusive to each other.'); } @@ -79,7 +79,7 @@ export class ApplicationCommandOptionWithChoicesAndAutocompleteMixin