Skip to content

Commit

Permalink
fix option type definition to match usage. (#1119)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
UrielCh authored and shadowspawn committed Jan 9, 2020
1 parent 491b2e4 commit 68e584f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions typings/index.d.ts
Expand Up @@ -159,17 +159,19 @@ declare namespace commander {
*
* @returns Command for chaining
*/
option(flags: string, description?: string, fn?: ((arg1: any, arg2: any) => void) | RegExp, defaultValue?: any): Command;
option(flags: string, description?: string, defaultValue?: any): Command;
option(flags: string, description?: string, defaultValue?: string | boolean): Command;
option(flags: string, description: string, regexp: RegExp, defaultValue?: string | boolean): Command;
option<T>(flags: string, description: string, fn: (value: string, previous: T) => T, defaultValue?: T): Command;

/**
* Define a required option, which must have a value after parsing. This usually means
* the option must be specified on the command line. (Otherwise the same as .option().)
*
* The `flags` string should contain both the short and long flags, separated by comma, a pipe or space.
*/
requiredOption(flags: string, description?: string, fn?: ((arg1: any, arg2: any) => void) | RegExp, defaultValue?: any): Command;
requiredOption(flags: string, description?: string, defaultValue?: any): Command;
requiredOption(flags: string, description?: string, defaultValue?: string | boolean): Command;
requiredOption(flags: string, description: string, regexp: RegExp, defaultValue?: string | boolean): Command;
requiredOption<T>(flags: string, description: string, fn: (value: string, previous: T) => T, defaultValue?: T): Command;


/**
Expand Down

0 comments on commit 68e584f

Please sign in to comment.