From 68e584f2ff0e27b1d40ee54d9d115c338e2d4a86 Mon Sep 17 00:00:00 2001 From: UrielCh Date: Thu, 9 Jan 2020 10:51:36 +0200 Subject: [PATCH] fix option type definition to match usage. (#1119) * 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 --- typings/index.d.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index d1a89d8c2..0a53fdf79 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -159,8 +159,9 @@ 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(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 @@ -168,8 +169,9 @@ declare namespace commander { * * 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(flags: string, description: string, fn: (value: string, previous: T) => T, defaultValue?: T): Command; /**