Skip to content
Myr

Simplify addHelpText TypeScript signature and improve typings test (#1516)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by John Gee · committed by GitHub · parent 59c8153 · Browse files · 2 files+5 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+5 added−6 removed

  • other:+5 added−6 removed

2 files+5 added−6 removed

modified:typings/index.d.ts+1 added-1 removed
638 unmodified lines
639 * Position is 'before' or 'after' to affect just this command,640 * and 'beforeAll' or 'afterAll' to affect this command and all its subcommands.641 */642 addHelpText(position: AddHelpTextPosition, text: string): this;643 addHelpText(position: AddHelpTextPosition, text: (context: AddHelpTextContext) => string | undefined): this;643 addHelpText(position: AddHelpTextPosition, text: (context: AddHelpTextContext) => string): this;644645 /**646 * Add a listener (callback) for when events occur. (Implemented using EventEmitter.)647 */
39 unmodified lines
modified:typings/index.test-d.ts+4 added-5 removed
222 unmodified lines
223// addHelpText224expectType<commander.Command>(program.addHelpText('after', 'text'));225expectType<commander.Command>(program.addHelpText('afterAll', 'text'));226expectType<commander.Command>(program.addHelpText('before', () => 'before'));227expectType<commander.Command>(program.addHelpText('beforeAll', (context: commander.AddHelpTextContext) => {228 if (context.error) {229 return; // Can return nothing to skip display230 }231 return context.command.name();227expectType<commander.Command>(program.addHelpText('beforeAll', (context) => {228 expectType<boolean>(context.error);229 expectType<commander.Command>(context.command);230 return '';231}));232233// on234expectType<commander.Command>(program.on('command:foo', () => {
120 unmodified lines