Skip to content
Myr

Modify return type depending on storeOptionsAsProperties parameter (#1424)

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 75c2a63 · Browse files · 2 files+15 added−1 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+15 added−1 removed

  • other:+15 added−1 removed

2 files+15 added−1 removed

modified:typings/commander-tests.ts+8 added
130 unmodified lines
131// addOption132const addOptionThis: commander.Command = program.addOption(new commander.Option('-s,--simple'));133134// storeOptionsAsProperties135// chaining136const storeOptionsAsPropertiesThis1: commander.Command = program.storeOptionsAsProperties();137const storeOptionsAsPropertiesThis2: commander.Command = program.storeOptionsAsProperties(false);138// return type depends on parameter139const storeOptionsAsPropertiesThis3 = program.storeOptionsAsProperties();140const storeOptionsAsPropertiesValue3 = storeOptionsAsPropertiesThis3.someOption;141const storeOptionsAsPropertiesThis4 = program.storeOptionsAsProperties(true);142const storeOptionsAsPropertiesValue4 = storeOptionsAsPropertiesThis4.someOption;143const storeOptionsAsPropertiesThis5 = program.storeOptionsAsProperties(false);144// const storeOptionsAsPropertiesValue5 = storeOptionsAsPropertiesThis5.someOption; // error145146// combineFlagAndOptionalValue147const combineFlagAndOptionalValueThis1: commander.Command = program.combineFlagAndOptionalValue();148const combineFlagAndOptionalValueThis2: commander.Command = program.combineFlagAndOptionalValue(false);
190 unmodified lines
modified:typings/index.d.ts+7 added-1 removed
146 unmodified lines
147 }148149 type AddHelpTextPosition = 'beforeAll' | 'before' | 'after' | 'afterAll';150151 interface OptionValues {152 [key: string]: any;153 }154155 interface Command {156 args: string[];157158 commands: Command[];
216 unmodified lines
375 * or store separately (specify false). In both cases the option values can be accessed using .opts().376 *377 * @returns `this` command for chaining378 */379 storeOptionsAsProperties(): this & OptionValues;380 storeOptionsAsProperties(storeAsProperties: true): this & OptionValues;381 storeOptionsAsProperties(storeAsProperties?: boolean): this;382383 /**384 * Alter parsing of short flags with optional values.
70 unmodified lines
455456 /**457 * Return an object containing options as key-value pairs458 */453 opts(): { [key: string]: any };459 opts(): OptionValues;460461 /**462 * Set the description.463 *
135 unmodified lines