From d77a70b25a338a28ac9e5d5a5f0e6f542a4581b7 Mon Sep 17 00:00:00 2001 From: LenAnderson Date: Sat, 18 May 2024 14:49:02 -0400 Subject: [PATCH] fix type hints --- public/scripts/slash-commands/SlashCommand.js | 24 +++++++++++++++++-- .../slash-commands/SlashCommandExecutor.js | 2 +- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/public/scripts/slash-commands/SlashCommand.js b/public/scripts/slash-commands/SlashCommand.js index 905967373..84e441e6b 100644 --- a/public/scripts/slash-commands/SlashCommand.js +++ b/public/scripts/slash-commands/SlashCommand.js @@ -1,5 +1,25 @@ +import { SlashCommandAbortController } from './SlashCommandAbortController.js'; import { SlashCommandArgument, SlashCommandNamedArgument } from './SlashCommandArgument.js'; import { SlashCommandClosure } from './SlashCommandClosure.js'; +import { PARSER_FLAG } from './SlashCommandParser.js'; +import { SlashCommandScope } from './SlashCommandScope.js'; + + + + +/** + * @typedef {{ + * _pipe:string|SlashCommandClosure, + * _scope:SlashCommandScope, + * _parserFlags:{[id:PARSER_FLAG]:boolean}, + * _abortController:SlashCommandAbortController, + * [id:string]:string, + * }} NamedArguments + */ + +/** + * @typedef {string|SlashCommandClosure|(string|SlashCommandClosure)[]} UnnamedArguments +*/ @@ -8,7 +28,7 @@ export class SlashCommand { * Creates a SlashCommand from a properties object. * @param {Object} props * @param {string} [props.name] - * @param {(namedArguments:Object., unnamedArguments:string|SlashCommandClosure|(string|SlashCommandClosure)[])=>string|SlashCommandClosure|void|Promise} [props.callback] + * @param {(namedArguments:NamedArguments, unnamedArguments:string|SlashCommandClosure|(string|SlashCommandClosure)[])=>string|SlashCommandClosure|void|Promise} [props.callback] * @param {string} [props.helpString] * @param {boolean} [props.splitUnnamedArgument] * @param {string[]} [props.aliases] @@ -25,7 +45,7 @@ export class SlashCommand { /**@type {string}*/ name; - /**@type {(namedArguments:Object, unnamedArguments:string|SlashCommandClosure|(string|SlashCommandClosure)[])=>string|SlashCommandClosure|Promise}*/ callback; + /**@type {(namedArguments:{_pipe:string|SlashCommandClosure, _scope:SlashCommandScope, _abortController:SlashCommandAbortController, [id:string]:string|SlashCommandClosure}, unnamedArguments:string|SlashCommandClosure|(string|SlashCommandClosure)[])=>string|SlashCommandClosure|Promise}*/ callback; /**@type {string}*/ helpString; /**@type {boolean}*/ splitUnnamedArgument = false; /**@type {string[]}*/ aliases = []; diff --git a/public/scripts/slash-commands/SlashCommandExecutor.js b/public/scripts/slash-commands/SlashCommandExecutor.js index 2cf0c4647..f64c37aff 100644 --- a/public/scripts/slash-commands/SlashCommandExecutor.js +++ b/public/scripts/slash-commands/SlashCommandExecutor.js @@ -20,7 +20,7 @@ export class SlashCommandExecutor { // @ts-ignore /**@type {SlashCommandNamedArgumentAssignment[]}*/ namedArgumentList = []; /**@type {SlashCommandUnnamedArgumentAssignment[]}*/ unnamedArgumentList = []; - /**@type {Object} */ parserFlags; + /**@type {{[id:PARSER_FLAG]:boolean}} */ parserFlags; get commandCount() { return 1