-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
Description
Lines 511 to 527 in 83c3f4e
| action(fn) { | |
| const listener = (args) => { | |
| // The .action callback takes an extra parameter which is the command or options. | |
| const expectedArgsCount = this.registeredArguments.length; | |
| const actionArgs = args.slice(0, expectedArgsCount); | |
| if (this._storeOptionsAsProperties) { | |
| actionArgs[expectedArgsCount] = this; // backwards compatible "options" | |
| } else { | |
| actionArgs[expectedArgsCount] = this.opts(); | |
| } | |
| actionArgs.push(this); | |
| return fn.apply(this, actionArgs); | |
| }; | |
| this._actionHandler = listener; | |
| return this; | |
| } |
The passed
action function fn receives the current command as this context in line 523. However, this context is missing in the current typings.commander.js/typings/index.d.ts
Line 525 in 83c3f4e
| action(fn: (...args: any[]) => void | Promise<void>): this; |
Happy to provide a PR for this!
Reactions are currently unavailable