Merge pull request #23966 from synarque/master

@types/inquirer: Added support for async return types being promises
This commit is contained in:
Nathan Shively-Sanders
2018-03-26 14:05:15 -07:00
committed by GitHub

View File

@@ -5,6 +5,7 @@
// Jouderian <https://github.com/jouderianjr>
// Qibang <https://github.com/bang88>
// Jason Dreyzehner <https://github.com/bitjson>
// Synarque <https://github.com/synarque>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
@@ -90,7 +91,7 @@ declare namespace inquirer {
* Default value(s) to use if nothing is entered, or a function that returns the default value(s).
* If defined as a function, the first parameter will be the current inquirer session answers.
*/
default?: any | ((answers: T) => any);
default?: any | ((answers: T) => any) | ((answers: T) => Promise<any>);
/**
* Choices array or a function returning a choices array. If defined as a function,
* the first parameter will be the current inquirer session answers.
@@ -99,22 +100,23 @@ declare namespace inquirer {
*/
choices?:
| ReadonlyArray<ChoiceType>
| ((answers: T) => ReadonlyArray<ChoiceType>);
| ((answers: T) => ReadonlyArray<ChoiceType>)
| ((answers: T) => Promise<ReadonlyArray<ChoiceType>>);
/**
* Receive the user input and should return true if the value is valid, and an error message (String)
* otherwise. If false is returned, a default error message is provided.
*/
validate?(input: string, answers?: T): boolean | string;
validate?(input: string, answers?: T): boolean | string | Promise<boolean | string>;
/**
* Receive the user input and return the filtered value to be used inside the program.
* The value returned will be added to the Answers hash.
*/
filter?(input: string): string;
filter?(input: string): string | Promise<string>;
/**
* Receive the current user answers hash and should return true or false depending on whether or
* not this question should be asked. The value can also be a simple boolean.
*/
when?: boolean | ((answers: T) => boolean);
when?: boolean | ((answers: T) => boolean) | ((answers: T) => Promise<boolean>);
paginated?: boolean;
/**
* Change the number of lines that will be rendered when using list, rawList, expand or checkbox.