Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[yargs] Add types for deprecate, deprecated, and deprecatedOptions #47867

Merged
merged 1 commit into from Oct 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions types/yargs/index.d.ts
Expand Up @@ -246,6 +246,11 @@ declare namespace yargs {
demandCommand(min: number, minMsg?: string): Argv<T>;
demandCommand(min: number, max?: number, minMsg?: string, maxMsg?: string): Argv<T>;

/**
* Shows a [deprecated] notice in front of the option
*/
deprecateOption(option: string, msg?: string): Argv<T>;

/**
* Describe a `key` for the generated usage information.
*
Expand Down Expand Up @@ -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()` */
Expand Down
10 changes: 10 additions & 0 deletions types/yargs/yargs-tests.ts
Expand Up @@ -805,6 +805,8 @@ function Argv$commandObject() {
defaultDescription: "description",
demand: true,
demandOption: true,
deprecate: true,
deprecated: "deprecated",
desc: "desc",
describe: "describe",
description: "description",
Expand Down Expand Up @@ -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')
Expand Down