Open jrieken opened 3 years ago
Would be really cool to have a way to bridge the gap with the package.json and check the type signatures of commands that are registered for certain things (example https://github.com/microsoft/vscode/pull/109049). Like maybe with a TS server plugin.
Today, in
vsocde.d.ts
we define a generic command (which is actually a command and minimal UI) and a way to execute any command. Namely these two symbolsexport function executeCommand<T>(command: string, ...rest: any[]): Thenable<T | undefined>;
export interface Command { title: string; command: string; tooltip?: string; arguments?: any[]; }
In the name of arbitrary commands this API is kept very generic. However, some commands are known, we call them API commands and they are currently only documented, see https://code.visualstudio.com/api/references/commands, offering no tooling.
So, in addition the generic approach we could invest in some TypeScript gymnastics that bring some specific overloads, so
executeCommand
something like this would work:However, I still struggle to find a nice way to reuse the
ApiCommandMap
to create specific overloads for theCommand
type. I have something like this in mind:The bottom line is that I want to make sure that a
Command
uses the right arguments when using a certain command identifier.