diff --git a/typings/commander-tests.ts b/typings/commander-tests.ts index 7661bcf0e..1c209d02c 100644 --- a/typings/commander-tests.ts +++ b/typings/commander-tests.ts @@ -45,6 +45,14 @@ function increaseVerbosity(v: any, total: number) { return total + 1; } +function syncCall() { + console.log("Sync success!"); +} + +async function asyncCall() { + return; +} + program .version('0.0.1') .usage('[options] ') @@ -111,7 +119,11 @@ program program .command("name1", "description") - .command("name2", "description", { isDefault:true }) + .command("name2", "description", { isDefault:true }); + +program + .command("name3").action(syncCall) + .command("name4").action(asyncCall); program .exitOverride(); diff --git a/typings/index.d.ts b/typings/index.d.ts index d1a89d8c2..082a3a3c2 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -115,7 +115,7 @@ declare namespace commander { * * @returns Command for chaining */ - action(fn: (...args: any[]) => void): Command; + action(fn: (...args: any[]) => void | Promise): Command; /** * Define option with `flags`, `description` and optional