We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents c113f09 + bef06f8 commit 2f20b23Copy full SHA for 2f20b23
packages/ghoulscript/src/rpc/call.ts
@@ -2,12 +2,15 @@ import * as core from '../core'
2
3
export type Core = typeof core
4
5
-export type Commands = keyof Core
+export type Commands = keyof Core & string
6
7
export type CommandArgs<C extends Commands> = Parameters<Core[C]>
8
9
export type CommandResult<C extends Commands> = ReturnType<Core[C]>
10
11
export async function callRPC<C extends Commands> (name: C, args: CommandArgs<C>): Promise<CommandResult<C>> {
12
+ if (typeof core[name] !== 'function')
13
+ throw new TypeError(`Invalid action: "${name}"`)
14
+
15
return await (core[name] as (...args: any[]) => Promise<any>)(...args)
16
}
0 commit comments