Fix type errors in extensions-slashcommands
| @@ -9,7 +9,8 @@ import { equalsIgnoreCaseAndAccents, isFalseBoolean, isTrueBoolean } from './uti | ||
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * @param {'enable' | 'disable' | 'toggle'} action - The action to perform on the extension |
| 12 | - * @returns {(args: {[key: string]: string | SlashCommandClosure}, extensionName: string | SlashCommandClosure) => Promise<string>} | |
| 12 | + * @typedef {import('./slash-commands/SlashCommand.js').NamedArguments | import('./slash-commands/SlashCommand.js').NamedArgumentsCapture} NamedArgumentsAssignment | |
| 13 | + * @returns {(args: NamedArgumentsAssignment, extensionName: string | SlashCommandClosure) => Promise<string>} | |
| 13 | 14 | */ |
| 14 | 15 | function getExtensionActionCallback(action) { |
| 15 | 16 | return async (args, extensionName) => { |
| @@ -20,7 +21,7 @@ function getExtensionActionCallback(action) { | ||
| 20 | 21 | return ''; |
| 21 | 22 | } |
| 22 | 23 | |
| 23 | 24 | const reload = !isFalseBoolean(args?.reload?.toString()); |
| 24 | 25 | const internalExtensionName = findExtension(extensionName); |
| 25 | 26 | if (!internalExtensionName) { |
| 26 | 27 | toastr.warning(`Extension ${extensionName} does not exist.`); |
| @@ -186,8 +187,8 @@ export function registerExtensionSlashCommands() { | ||
| 186 | 187 | if (args?.state instanceof SlashCommandClosure) throw new Error('\'state\' argument cannot be a closure.'); |
| 187 | 188 | if (typeof extensionName !== 'string') throw new Error('Extension name must be a string. Closures or arrays are not allowed.'); |
| 188 | 189 | |
| 189 | 190 | const action = isTrueBoolean(args?.state?.toString()) ? 'enable' : |
| 190 | 191 | isFalseBoolean(args?.state?.toString()) ? 'disable' : |
| 191 | 192 | 'toggle'; |
| 192 | 193 | |
| 193 | 194 | return await getExtensionActionCallback(action)(args, extensionName); |