Skip to content

rpc add

Extend a panel’s RPC contract: appends a method to its interface in src/shared/api.ts and adds a handler stub in the panel.

Terminal window
vsceasy rpc add --panel dashboard --method getStats --returns "Promise<Stats>"

Flags

FlagTypeNotes
--panelpanel idRequired. Which panel to extend.
--methodtextRequired. Method name.
--paramstextParam signature, e.g. id: string, q?: string.
--returnstextReturn type. Default void.

Examples

Terminal window
# no args, returns a value
vsceasy rpc add --panel dashboard --method getStats --returns "{ total: number }"
# with params
vsceasy rpc add --panel users --method find --params "q: string" --returns "User[]"

This adds to both sides:

src/shared/api.ts
export interface DashboardApi {
getStats(): Promise<{ total: number }>; // ← added
}
src/panels/dashboard.ts
rpc: (vscode) => ({
async getStats() {
// TODO: implement
return { total: 0 };
},
}),

Call it from the webview with full typing — see Typed RPC.