diff --git a/lib/command.js b/lib/command.js index 590a271dd..4a9867cb1 100644 --- a/lib/command.js +++ b/lib/command.js @@ -780,7 +780,7 @@ Expecting one of '${allowedValues.join("', '")}'`); */ setOptionValue(key, value) { - return this.setOptionValueWithSource(key, value, undefined); + return this.setOptionValueWithSource(key, value); } /** @@ -788,7 +788,7 @@ Expecting one of '${allowedValues.join("', '")}'`); * * @param {string} key * @param {Object} value - * @param {string} source - expected values are default/config/env/cli/implied + * @param {string} [source] - expected values are default/config/env/cli/implied * @return {Command} `this` command for chaining */ @@ -807,7 +807,7 @@ Expecting one of '${allowedValues.join("', '")}'`); * Expected values are default | config | env | cli | implied * * @param {string} key - * @return {string} + * @return {string | undefined} */ getOptionValueSource(key) { @@ -819,7 +819,7 @@ Expecting one of '${allowedValues.join("', '")}'`); * Expected values are default | config | env | cli | implied * * @param {string} key - * @return {string} + * @return {string | undefined} */ getOptionValueSourceWithGlobals(key) { diff --git a/typings/index.d.ts b/typings/index.d.ts index 695c3bd25..8fa682e20 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -595,17 +595,17 @@ export class Command { /** * Store option value and where the value came from. */ - setOptionValueWithSource(key: string, value: unknown, source: OptionValueSource): this; + setOptionValueWithSource(key: string, value: unknown, source?: OptionValueSource | string | undefined): this; /** * Get source of option value. */ - getOptionValueSource(key: string): OptionValueSource | undefined; + getOptionValueSource(key: string): OptionValueSource | string | undefined; /** * Get source of option value. See also .optsWithGlobals(). */ - getOptionValueSourceWithGlobals(key: string): OptionValueSource | undefined; + getOptionValueSourceWithGlobals(key: string): OptionValueSource | string | undefined; /** * Alter parsing of short flags with optional values. diff --git a/typings/index.test-d.ts b/typings/index.test-d.ts index 734036fad..5d83446da 100644 --- a/typings/index.test-d.ts +++ b/typings/index.test-d.ts @@ -173,10 +173,10 @@ expectType(program.setOptionValue('example', true)); expectType(program.setOptionValueWithSource('example', [], 'cli')); // getOptionValueSource -expectType(program.getOptionValueSource('example')); +expectType(program.getOptionValueSource('example')); // getOptionValueSourceWithGlobals -expectType(program.getOptionValueSourceWithGlobals('example')); +expectType(program.getOptionValueSourceWithGlobals('example')); // combineFlagAndOptionalValue expectType(program.combineFlagAndOptionalValue());