From ebd430ff8444a9968aee6edcb4a13d29f33e1f61 Mon Sep 17 00:00:00 2001 From: Lindsey Date: Thu, 1 Feb 2018 14:13:19 -0500 Subject: [PATCH] [meow] Upgrade types for version 4 (#23350) * [meow] Upgrade types for version 4 * Use ES6 import style --- types/meow/index.d.ts | 16 +++++++++---- types/meow/meow-tests.ts | 50 ++++++++++++++++++++++++++++------------ 2 files changed, 46 insertions(+), 20 deletions(-) diff --git a/types/meow/index.d.ts b/types/meow/index.d.ts index 2585d421ae..20e40c63f7 100644 --- a/types/meow/index.d.ts +++ b/types/meow/index.d.ts @@ -1,11 +1,13 @@ -// Type definitions for meow 3.6 +// Type definitions for meow 4.x // Project: https://github.com/sindresorhus/meow -// Definitions by: KnisterPeter +// Definitions by: KnisterPeter , Lindsey Smith // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 -import * as minimist from 'minimist'; +import * as buildOptions from "minimist-options"; -declare function meow(options: string | string[] | meow.Options, minimistOptions?: minimist.Opts): meow.Result; +declare function meow(helpMessage: string | string[], options: meow.Options): meow.Result; +declare function meow(options: string | string[] | meow.Options): meow.Result; declare namespace meow { interface Options { description?: string | boolean; @@ -14,14 +16,18 @@ declare namespace meow { pkg?: any; argv?: string[]; inferType?: boolean; + flags?: buildOptions.Options; + autoHelp?: boolean; + autoVersion?: boolean; } interface Result { input: string[]; flags: { [name: string]: any }; - pkg: any; + pkg: object; help: string; showHelp(code?: number): void; + showVersion(): void; } } diff --git a/types/meow/meow-tests.ts b/types/meow/meow-tests.ts index 6560b76bef..8915603292 100644 --- a/types/meow/meow-tests.ts +++ b/types/meow/meow-tests.ts @@ -1,19 +1,39 @@ import meow = require('meow'); -import Options = meow.Options; -const options: Options = {}; -options.description = true; -options.description = 'string'; -options.help = true; -options.help = 'string'; -options.version = true; -options.version = 'string'; -options.argv = ['string', 'string']; -options.inferType = true; +const cli = meow("Help text", + { + flags: { + unicorn: { + type: 'boolean', + alias: 'u' + }, + fooBar: { + type: 'string', + default: 'foo' + } + } + } +); -meow(options); -meow('Usage text', { - alias: { - opt: 'opt' - } +const cli2 = meow("Help text"); + +const cli3 = meow({ + description: "version string", + help: "help string", + version: "1.0.0", + pkg: {}, + argv: ['foo', 'bar'], + inferType: true, + autoHelp: true, + autoVersion: true, + flags: { + unicorn: { + type: 'boolean', + alias: 'u' + }, + fooBar: { + type: 'string', + default: 'foo' + } + } });