From 61892ba3012bd844181c33c2be10e05f6ea8dfcd Mon Sep 17 00:00:00 2001 From: Nathan Yocum Date: Mon, 21 Sep 2020 14:26:07 -0700 Subject: [PATCH] Add types for deprecate, deprecated, and deprecatedOptions --- types/yargs/index.d.ts | 9 +++++++++ types/yargs/yargs-tests.ts | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/types/yargs/index.d.ts b/types/yargs/index.d.ts index 8f34069faef077..fccdc9b9c8bf3b 100644 --- a/types/yargs/index.d.ts +++ b/types/yargs/index.d.ts @@ -246,6 +246,11 @@ declare namespace yargs { demandCommand(min: number, minMsg?: string): Argv; demandCommand(min: number, max?: number, minMsg?: string, maxMsg?: string): Argv; + /** + * Shows a [deprecated] notice in front of the option + */ + deprecateOption(option: string, msg?: string): Argv; + /** * Describe a `key` for the generated usage information. * @@ -645,6 +650,10 @@ declare namespace yargs { * Use 'demandOption' instead */ demand?: boolean | string; + /** boolean or string, mark the argument as deprecated, see `deprecateOption()` */ + deprecate?: boolean | string; + /** boolean or string, mark the argument as deprecated, see `deprecateOption()` */ + deprecated?: boolean | string; /** boolean or string, demand the option be given, with optional error message, see `demandOption()` */ demandOption?: boolean | string; /** string, the option description for help content, see `describe()` */ diff --git a/types/yargs/yargs-tests.ts b/types/yargs/yargs-tests.ts index e462be6e6c9a01..b0ddd4765b114f 100644 --- a/types/yargs/yargs-tests.ts +++ b/types/yargs/yargs-tests.ts @@ -805,6 +805,8 @@ function Argv$commandObject() { defaultDescription: "description", demand: true, demandOption: true, + deprecate: true, + deprecated: "deprecated", desc: "desc", describe: "describe", description: "description", @@ -842,6 +844,14 @@ function Argv$demandOption() { .argv; } +function Argv$deprecateOption() { + const ya = yargs + .option('old', {}) + .deprecateOption('old', 'use --new') + .option('new', {}) + .argv; +} + function Argv$conflicts() { const ya = yargs .conflicts('a', 'b')