From 0e3c0e8c13da5703dd3c067d07c514ee49a4dcb0 Mon Sep 17 00:00:00 2001 From: bcoe Date: Sun, 2 May 2021 11:51:09 -0700 Subject: [PATCH] fail should accept boolean --- types/yargs/index.d.ts | 2 +- types/yargs/yargs-tests.ts | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/types/yargs/index.d.ts b/types/yargs/index.d.ts index 86977f0ec4fee9..96562bdcbfd376 100644 --- a/types/yargs/index.d.ts +++ b/types/yargs/index.d.ts @@ -333,7 +333,7 @@ declare namespace yargs { * Method to execute when a failure occurs, rather than printing the failure message. * @param func Is called with the failure message that would have been printed, the Error instance originally thrown and yargs state when the failure occurred. */ - fail(func: (msg: string, err: Error, yargs: Argv) => any): Argv; + fail(func: ((msg: string, err: Error, yargs: Argv) => any) | boolean): Argv; /** * Allows to programmatically get completion choices for any line. diff --git a/types/yargs/yargs-tests.ts b/types/yargs/yargs-tests.ts index fdcad1bd4dfcdc..612b16814c0dfa 100644 --- a/types/yargs/yargs-tests.ts +++ b/types/yargs/yargs-tests.ts @@ -660,6 +660,12 @@ function Argv$fail() { process.exit(1); }) .argv; + + // Providing false as a value for fn can be used to prevent yargs from + // exiting and printing a failure message + const ya2 = yargs + .fail(false) + .argv; } function Argv$implies() {