diff --git a/yargs/yargs-tests.ts b/yargs/yargs-tests.ts
index c964e1b724..9246bf4725 100644
--- a/yargs/yargs-tests.ts
+++ b/yargs/yargs-tests.ts
@@ -4,8 +4,9 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
///
+///
-import yargs = require('yargs');
+import * as yargs from 'yargs';
// Examples taken from yargs website
// https://github.com/chevex/yargs
@@ -343,3 +344,15 @@ function Argv$commandDirWithOptions() {
})
.argv
}
+
+// http://yargs.js.org/docs/#methods-failfn
+function Argv$fail() {
+ var argv = yargs
+ .fail(function (msg, err) {
+ if (err) throw err // preserve stack
+ console.error('You broke it!')
+ console.error(msg)
+ process.exit(1)
+ })
+ .argv
+}
diff --git a/yargs/yargs.d.ts b/yargs/yargs.d.ts
index e2f329e3c0..547b6e9e63 100644
--- a/yargs/yargs.d.ts
+++ b/yargs/yargs.d.ts
@@ -135,7 +135,7 @@ declare module "yargs" {
count(key: string): Argv;
count(keys: string[]): Argv;
- fail(func: (msg: string) => any): void;
+ fail(func: (msg: string, err: Error) => any): Argv;
}
interface RequireDirectoryOptions {