// Type definitions for prompts 2.0 // Project: https://github.com/terkelg/prompts // Definitions by: Berkay GURSOY // Daniel Perez Alvarez // Kamontat Chantrachirathumrong // theweirdone // whoaa512 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.9 export = prompts; declare function prompts( questions: prompts.PromptObject | Array>, options?: prompts.Options ): Promise>; declare namespace prompts { // Circular reference from prompts const prompt: any; function inject(arr: ReadonlyArray): void; namespace inject { const prototype: {}; } function override(obj: { [key: string]: any }): void; namespace override { const prototype: {}; } namespace prompts { function autocomplete(args: PromptObject): any; function confirm(args: PromptObject): void; function date(args: PromptObject): any; function invisible(args: PromptObject): any; function list(args: PromptObject): any; function multiselect(args: PromptObject): any; function number(args: PromptObject): void; function password(args: PromptObject): any; function select(args: PromptObject): void; function text(args: PromptObject): void; function toggle(args: PromptObject): void; } interface Choice { title: string; value: any; disable?: boolean; description?: string; } interface Options { onSubmit?: (prompt: PromptObject, answer: any, answers: any[]) => void; onCancel?: (prompt: PromptObject, answers: any) => void; } interface PromptObject { type: PromptType | Falsy | PrevCaller; name: ValueOrFunc; message?: ValueOrFunc; initial?: string | number | boolean | Date; style?: string; format?: PrevCaller; validate?: PrevCaller>; onState?: PrevCaller; min?: number; max?: number; float?: boolean; round?: number; increment?: number; seperator?: string; active?: string; inactive?: string; choices?: Choice[]; hint?: string; suggest?: ((input: any, choices: Choice[]) => Promise); limit?: number; mask?: string; } type Answers = { [id in T]: any }; type PrevCaller = ( prev: any, values: Answers, prompt: PromptObject ) => R; type Falsy = false | null | undefined; type PromptType = "text" | "password" | "invisible" | "number" | "confirm" | "list" | "toggle" | "select" | "multiselect" | "autocomplete" | "date" | "autocompleteMultiselect"; type ValueOrFunc = T | PrevCaller; }