From dd878f4839ceafe8b55ff64cf5c7ff1de6d08629 Mon Sep 17 00:00:00 2001 From: Jason Dreyzehner Date: Mon, 5 Mar 2018 23:22:44 -0500 Subject: [PATCH 1/2] meow: array params are not required to be mutable --- types/meow/index.d.ts | 17 ++++++++++++----- types/meow/meow-tests.ts | 36 +++++++++++++++++++----------------- 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/types/meow/index.d.ts b/types/meow/index.d.ts index 20e40c63f7..98004a1a9a 100644 --- a/types/meow/index.d.ts +++ b/types/meow/index.d.ts @@ -1,20 +1,27 @@ // Type definitions for meow 4.x // Project: https://github.com/sindresorhus/meow -// Definitions by: KnisterPeter , Lindsey Smith +// Definitions by: KnisterPeter +// Lindsey Smith +// Jason Dreyzehner // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 -import * as buildOptions from "minimist-options"; +import * as buildOptions from 'minimist-options'; -declare function meow(helpMessage: string | string[], options: meow.Options): meow.Result; -declare function meow(options: string | string[] | meow.Options): meow.Result; +declare function meow( + helpMessage: string | ReadonlyArray, + options: meow.Options +): meow.Result; +declare function meow( + options: string | ReadonlyArray | meow.Options +): meow.Result; declare namespace meow { interface Options { description?: string | boolean; help?: string | boolean; version?: string | boolean; pkg?: any; - argv?: string[]; + argv?: ReadonlyArray; inferType?: boolean; flags?: buildOptions.Options; autoHelp?: boolean; diff --git a/types/meow/meow-tests.ts b/types/meow/meow-tests.ts index 8915603292..2a0820b33c 100644 --- a/types/meow/meow-tests.ts +++ b/types/meow/meow-tests.ts @@ -1,28 +1,30 @@ import meow = require('meow'); -const cli = meow("Help text", - { - flags: { - unicorn: { - type: 'boolean', - alias: 'u' - }, - fooBar: { - type: 'string', - default: 'foo' - } +const cli = meow('Help text', { + flags: { + unicorn: { + type: 'boolean', + alias: 'u' + }, + fooBar: { + type: 'string', + default: 'foo' } } -); +}); -const cli2 = meow("Help text"); +const input: string = cli.input[0]; + +const cli2 = meow('Help text'); + +const args: ReadonlyArray = ['foo', 'bar']; const cli3 = meow({ - description: "version string", - help: "help string", - version: "1.0.0", + description: 'version string', + help: 'help string', + version: '1.0.0', pkg: {}, - argv: ['foo', 'bar'], + argv: args, inferType: true, autoHelp: true, autoVersion: true, From 6eb0a51a6916b989171710e868f646e9b2f6032e Mon Sep 17 00:00:00 2001 From: Jason Dreyzehner Date: Mon, 5 Mar 2018 23:25:59 -0500 Subject: [PATCH 2/2] meow: Result.pkg should return any, not object https://github.com/Microsoft/TypeScript/issues/15225#issuecomment-294565052 --- types/meow/index.d.ts | 2 +- types/meow/meow-tests.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/types/meow/index.d.ts b/types/meow/index.d.ts index 98004a1a9a..db3d697691 100644 --- a/types/meow/index.d.ts +++ b/types/meow/index.d.ts @@ -31,7 +31,7 @@ declare namespace meow { interface Result { input: string[]; flags: { [name: string]: any }; - pkg: object; + pkg: any; help: string; showHelp(code?: number): void; showVersion(): void; diff --git a/types/meow/meow-tests.ts b/types/meow/meow-tests.ts index 2a0820b33c..1b044881b5 100644 --- a/types/meow/meow-tests.ts +++ b/types/meow/meow-tests.ts @@ -14,6 +14,7 @@ const cli = meow('Help text', { }); const input: string = cli.input[0]; +const version: string = cli.pkg.version; const cli2 = meow('Help text');