From 2564b3e01f0167e0291a56c1e385be7c4025ff4c Mon Sep 17 00:00:00 2001 From: bcoe Date: Sat, 3 Apr 2021 16:07:22 -0700 Subject: [PATCH] test: address failures --- types/yargs/v16/helpers.d.ts | 5 +++++ types/yargs/v16/tsconfig.json | 12 ++++++++++-- types/yargs/v16/yargs-tests.ts | 20 ++++++++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 types/yargs/v16/helpers.d.ts diff --git a/types/yargs/v16/helpers.d.ts b/types/yargs/v16/helpers.d.ts new file mode 100644 index 000000000000000..6ed18149ab12973 --- /dev/null +++ b/types/yargs/v16/helpers.d.ts @@ -0,0 +1,5 @@ +import * as Parser from 'yargs-parser'; + +export function applyExtends(config: Record, cwd: string, mergeExtends: boolean): Record; +export function hideBin(argv: string[]): string[]; +export { Parser }; diff --git a/types/yargs/v16/tsconfig.json b/types/yargs/v16/tsconfig.json index 8f371eb527182bd..33668ffc47df091 100644 --- a/types/yargs/v16/tsconfig.json +++ b/types/yargs/v16/tsconfig.json @@ -8,9 +8,17 @@ "noImplicitThis": true, "strictNullChecks": true, "strictFunctionTypes": true, - "baseUrl": "../", + "baseUrl": "../../", + "paths": { + "yargs": [ + "yargs/v16" + ], + "yargs/*": [ + "yargs/v16/*" + ] + }, "typeRoots": [ - "../" + "../../" ], "types": [], "noEmit": true, diff --git a/types/yargs/v16/yargs-tests.ts b/types/yargs/v16/yargs-tests.ts index ab18b224932dd00..5607a6f59bcb06e 100644 --- a/types/yargs/v16/yargs-tests.ts +++ b/types/yargs/v16/yargs-tests.ts @@ -1,6 +1,7 @@ /// import yargs = require('yargs'); +import yargsHelpers = require('yargs/helpers'); import yargsSingleton = require('yargs/yargs'); import * as fs from 'fs'; @@ -1307,3 +1308,22 @@ function Argv$strictCommands() { const argv1 = yargs.strictCommands().command('foo', 'foo command').argv; const argv2 = yargs.strictCommands(true).command('foo', 'foo command').argv; } + +function Argv$applyExtendsHelper() { + // $ExpectType Record + const arvg = yargsHelpers.applyExtends( + { extends: './package.json', apple: 'red' }, + process.cwd(), + true + ); +} + +function Argv$hideBinHelper() { + // $ExpectType string[] + const arvg = yargsHelpers.hideBin(process.argv); +} + +function Argv$ParserHelper() { + // $ExpectType Arguments + const argv = yargsHelpers.Parser('--foo --bar=99'); +}