From bc2147e2b91880f8bfc1d6ba27bd72d6d8bcacb6 Mon Sep 17 00:00:00 2001 From: Alban Gicquel Date: Mon, 26 Feb 2018 16:44:43 -0500 Subject: [PATCH 1/2] Added support for async return types being promises as stipulated by inquirer doc --- types/inquirer/index.d.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/types/inquirer/index.d.ts b/types/inquirer/index.d.ts index 67d8fd29ac..37141876a7 100644 --- a/types/inquirer/index.d.ts +++ b/types/inquirer/index.d.ts @@ -4,6 +4,7 @@ // Parvez // Jouderian // Qibang +// Synarque // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -89,29 +90,29 @@ 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); /** * Choices array or a function returning a choices array. If defined as a function, * the first parameter will be the current inquirer session answers. * Array values can be simple strings, or objects containing a name (to display) and a value properties * (to save in the answers hash). Values can also be a Separator. */ - choices?: ChoiceType[] | ((answers: T) => ChoiceType[]); + choices?: ChoiceType[] | ((answers: T) => ChoiceType[]) | ((answers: T) => Promise); /** * 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; /** * 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; /** * 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); paginated?: boolean; /** * Change the number of lines that will be rendered when using list, rawList, expand or checkbox. From 5ebbb231c8ca23e47ed4c240b8bb67fb7a73df96 Mon Sep 17 00:00:00 2001 From: Alban Gicquel Date: Mon, 19 Mar 2018 10:16:43 -0400 Subject: [PATCH 2/2] typo in merge --- types/inquirer/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/inquirer/index.d.ts b/types/inquirer/index.d.ts index 7c4e9a1f2e..e2e897741d 100644 --- a/types/inquirer/index.d.ts +++ b/types/inquirer/index.d.ts @@ -100,7 +100,7 @@ declare namespace inquirer { */ choices?: | ReadonlyArray - | ((answers: T) => ReadonlyArray); + | ((answers: T) => ReadonlyArray) | ((answers: T) => Promise>); /** * Receive the user input and should return true if the value is valid, and an error message (String)