[improve] Improve type of prompts

This commit is contained in:
Kamontat Chantrachirathumrong
2018-11-28 22:57:47 +01:00
committed by GitHub
parent 09832c50db
commit 850c8337b5
+5 -3
View File
@@ -52,12 +52,12 @@ declare namespace prompts {
}
interface Options {
onSubmit: (prompt: PromptObject, answer: any, answers: any[]) => void;
onCancel: (prompt: PromptObject, answers: any) => void;
onSubmit?: (prompt: PromptObject, answer: any, answers: any[]) => void;
onCancel?: (prompt: PromptObject, answers: any) => void;
}
interface PromptObject<T extends string = string> {
type: ValueOrFunc<string> | Falsy;
type: ValueOrFunc<PromptType> | Falsy;
name: ValueOrFunc<T>;
message?: ValueOrFunc<string>;
initial?: string | number | boolean;
@@ -89,5 +89,7 @@ declare namespace prompts {
type Falsy = false | null | undefined;
type PromptType = "text" | "password" | "invisible" | "number" | "confirm" | "list" | "toggle" | "select" | "multiselect" | "autocomplete" | Falsy
type ValueOrFunc<T extends string> = T | PrevCaller<T>;
}