Skip to content
Myr

fix option type definition to match usage. (#1119)

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

* fix option type def * add test improve types * change definition order * change def order * fix typing * improve typing enforce current implementation * final patch * drop all void returning option * fix missing boolean type for default value * clean code * clean code

authored by UrielCh · committed by John Gee · parent 491b2e4 · Browse files · 1 file+6 added−4 removed
This commit

State

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

Diff stats

1 file+6 added−4 removed

  • other:+6 added−4 removed

1 file+6 added−4 removed

modified:typings/index.d.ts+6 added-4 removed
157 unmodified lines
158 * program.option('-c, --cheese [type]', 'add cheese [marble]');159 *160 * @returns Command for chaining161 */162 option(flags: string, description?: string, fn?: ((arg1: any, arg2: any) => void) | RegExp, defaultValue?: any): Command;163 option(flags: string, description?: string, defaultValue?: any): Command;162 option(flags: string, description?: string, defaultValue?: string | boolean): Command;163 option(flags: string, description: string, regexp: RegExp, defaultValue?: string | boolean): Command;164 option<T>(flags: string, description: string, fn: (value: string, previous: T) => T, defaultValue?: T): Command;165166 /**167 * Define a required option, which must have a value after parsing. This usually means168 * the option must be specified on the command line. (Otherwise the same as .option().)169 *170 * The `flags` string should contain both the short and long flags, separated by comma, a pipe or space.171 */171 requiredOption(flags: string, description?: string, fn?: ((arg1: any, arg2: any) => void) | RegExp, defaultValue?: any): Command;172 requiredOption(flags: string, description?: string, defaultValue?: any): Command;172 requiredOption(flags: string, description?: string, defaultValue?: string | boolean): Command;173 requiredOption(flags: string, description: string, regexp: RegExp, defaultValue?: string | boolean): Command;174 requiredOption<T>(flags: string, description: string, fn: (value: string, previous: T) => T, defaultValue?: T): Command;175176177 /**178 * Whether to store option values as properties on command object,
135 unmodified lines