diff --git a/typings/commander-tests.ts b/typings/commander-tests.ts index 57392c667..3bdad012c 100644 --- a/typings/commander-tests.ts +++ b/typings/commander-tests.ts @@ -81,6 +81,7 @@ const optionThis1: commander.Command = program.option('-a,--alpha'); const optionThis2: commander.Command = program.option('-p, --peppers', 'Add peppers'); const optionThis3: commander.Command = program.option('-s, --string [value]', 'default string', 'value'); const optionThis4: commander.Command = program.option('-b, --boolean', 'default boolean', false); +const optionThis5: commander.Command = program.option('-o, --object [value]', 'default object', {key: 'value'}); // example coercion functions from README @@ -104,13 +105,13 @@ function commaSeparatedList(value: string, dummyPrevious: string[]): string[] { return value.split(','); } -const optionThis5: commander.Command = program.option('-f, --float ', 'float argument', parseFloat); -const optionThis6: commander.Command = program.option('-f, --float ', 'float argument', parseFloat, 3.2); -const optionThis7: commander.Command = program.option('-i, --integer ', 'integer argument', myParseInt); -const optionThis8: commander.Command = program.option('-i, --integer ', 'integer argument', myParseInt, 5); -const optionThis9: commander.Command = program.option('-v, --verbose', 'verbosity that can be increased', increaseVerbosity, 0); -const optionThis10: commander.Command = program.option('-c, --collect ', 'repeatable value', collect, []); -const optionThis11: commander.Command = program.option('-l, --list ', 'comma separated list', commaSeparatedList); +const optionThis6: commander.Command = program.option('-f, --float ', 'float argument', parseFloat); +const optionThis7: commander.Command = program.option('-f, --float ', 'float argument', parseFloat, 3.2); +const optionThis8: commander.Command = program.option('-i, --integer ', 'integer argument', myParseInt); +const optionThis9: commander.Command = program.option('-i, --integer ', 'integer argument', myParseInt, 5); +const optionThis10: commander.Command = program.option('-v, --verbose', 'verbosity that can be increased', increaseVerbosity, 0); +const optionThis11: commander.Command = program.option('-c, --collect ', 'repeatable value', collect, []); +const optionThis12: commander.Command = program.option('-l, --list ', 'comma separated list', commaSeparatedList); // requiredOption, same tests as option const requiredOptionThis1: commander.Command = program.requiredOption('-a,--alpha'); diff --git a/typings/index.d.ts b/typings/index.d.ts index c8061ffb3..01ba40bd8 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -171,8 +171,8 @@ declare namespace commander { * * @returns `this` command for chaining */ - option(flags: string, description?: string, defaultValue?: string | boolean): this; - option(flags: string, description: string, regexp: RegExp, defaultValue?: string | boolean): this; + option(flags: string, description?: string, defaultValue?: any): this; + option(flags: string, description: string, regexp: RegExp, defaultValue?: any): this; option(flags: string, description: string, fn: (value: string, previous: T) => T, defaultValue?: T): this; /** @@ -181,8 +181,8 @@ 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, defaultValue?: string | boolean): this; - requiredOption(flags: string, description: string, regexp: RegExp, defaultValue?: string | boolean): this; + requiredOption(flags: string, description?: string, defaultValue?: any): this; + requiredOption(flags: string, description: string, regexp: RegExp, defaultValue?: any): this; requiredOption(flags: string, description: string, fn: (value: string, previous: T) => T, defaultValue?: T): this; /**