diff --git a/types/meow/index.d.ts b/types/meow/index.d.ts index 20e40c63f7..db3d697691 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; @@ -24,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 8915603292..1b044881b5 100644 --- a/types/meow/meow-tests.ts +++ b/types/meow/meow-tests.ts @@ -1,28 +1,31 @@ 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 version: string = cli.pkg.version; + +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,