Skip to content

Commit c4782f1

Browse files
committed
refactor(registerCommands): tighten command map value type
Replace the residual `any` in the command-callback map value with a `CommandCallback` alias of `(...args: any[]) => unknown`. Mirrors VS Code's own `commands.registerCommand` signature while narrowing the return to `unknown` so callers must inspect before use. Rest-args stay `any[]` intentionally: the callbacks in this map are heterogeneous (`importSettings` takes an optional `filePath?: string`, the rest take none), and VS Code dispatches positional args dynamically — a single tight per-arity type would be lossy without splitting the map.
1 parent c4592be commit c4782f1

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/activate/registerCommands.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,19 @@ export const registerCommands = (options: RegisterCommandOptions) => {
7777
// `registerRipgrepDiagnosticCommand` (above), which owns the OutputChannel
7878
// lifecycle alongside the command registration, so it's intentionally
7979
// excluded from this map.
80+
//
81+
// Callback shape mirrors VS Code's own `commands.registerCommand` signature
82+
// (`(...args: any[]) => any`), with the return narrowed to `unknown` so
83+
// callers must inspect before using. `any[]` for args is unavoidable: the
84+
// callbacks here are heterogeneous (`importSettings` takes an optional
85+
// `filePath?: string`, others take none) and VS Code dispatches positional
86+
// args dynamically.
87+
type CommandCallback = (...args: any[]) => unknown
8088
const getCommandsMap = ({
8189
context,
8290
outputChannel,
8391
provider,
84-
}: RegisterCommandOptions): Record<Exclude<CommandId, "showRipgrepDiagnostic">, any> => ({
92+
}: RegisterCommandOptions): Record<Exclude<CommandId, "showRipgrepDiagnostic">, CommandCallback> => ({
8593
activationCompleted: () => {},
8694
plusButtonClicked: async () => {
8795
const visibleProvider = getVisibleProviderOrLog(outputChannel)

0 commit comments

Comments
 (0)