mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-11-29 09:41:45 +00:00
[improve] Improve type of prompts
This commit is contained in:
Vendored
+5
-3
@@ -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>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user