// Type definitions for prompts 2.04 // Project: https://github.com/terkelg/prompts // Definitions by: Berkay GURSOY // Daniel Perez Alvarez // Kamontat Chantrachirathumrong // theweirdone // 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(obj: any): void; namespace inject { 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: string; disable?: boolean; } interface Options { onSubmit?: (prompt: PromptObject, answer: any, answers: any[]) => void; onCancel?: (prompt: PromptObject, answers: any) => void; } interface PromptObject { type: ValueOrFunc | Falsy; 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?: ((prev: any, values: any, prompt: PromptObject) => void); 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"; type ValueOrFunc = T | PrevCaller; }