UNPKG

3.56 kBTypeScriptView Raw
1/**
2 * Inquirer.js
3 * A collection of common interactive command line user interfaces.
4 */
5import { Separator } from '@inquirer/prompts';
6import type { Prettify, UnionToIntersection } from '@inquirer/type';
7import { default as PromptsRunner } from './ui/prompt.js';
8import type { LegacyPromptConstructor, PromptFn } from './ui/prompt.js';
9import type { Answers, Question, QuestionAnswerMap, QuestionObservable, StreamOptions } from './types.js';
10export type { QuestionMap } from './types.js';
11type PromptReturnType<T> = (Promise<Prettify<T>> & {
12 ui: PromptsRunner<Prettify<T>>;
13}) | never;
14/**
15 * Create a new self-contained prompt module.
16 */
17export declare function createPromptModule(opt?: StreamOptions): {
18 <const AnswerList extends readonly Answers[], PrefilledAnswers extends Answers = object>(questions: { [I in keyof AnswerList]: Question<PrefilledAnswers & AnswerList[I]>; }, answers?: PrefilledAnswers): PromptReturnType<PrefilledAnswers & UnionToIntersection<AnswerList[number]>>;
19 <const Map extends QuestionAnswerMap<A>, const A extends Answers<Extract<keyof Map, string>>, PrefilledAnswers extends Answers = object>(questions: Map, answers?: PrefilledAnswers): PromptReturnType<PrefilledAnswers & A>;
20 <const A extends Answers, PrefilledAnswers extends Answers = object>(questions: QuestionObservable<A>, answers?: PrefilledAnswers): PromptReturnType<PrefilledAnswers & A>;
21 <const A extends Answers, PrefilledAnswers extends Answers = object>(questions: Question<A>, answers?: PrefilledAnswers): PromptReturnType<PrefilledAnswers & A>;
22 prompts: {
23 [x: string]: LegacyPromptConstructor | PromptFn<any, any>;
24 };
25 /**
26 * Register a prompt type
27 */
28 registerPrompt(name: string, prompt: LegacyPromptConstructor | PromptFn): any;
29 /**
30 * Register the defaults provider prompts
31 */
32 restoreDefaultPrompts(): void;
33};
34declare function registerPrompt(name: string, newPrompt: LegacyPromptConstructor): void;
35declare function restoreDefaultPrompts(): void;
36declare const inquirer: {
37 prompt: {
38 <const AnswerList extends readonly Answers[], PrefilledAnswers extends Answers = object>(questions: { [I in keyof AnswerList]: Question<PrefilledAnswers & AnswerList[I]>; }, answers?: PrefilledAnswers): PromptReturnType<PrefilledAnswers & UnionToIntersection<AnswerList[number]>>;
39 <const Map extends QuestionAnswerMap<A>, const A extends Answers<Extract<keyof Map, string>>, PrefilledAnswers extends Answers = object>(questions: Map, answers?: PrefilledAnswers): PromptReturnType<PrefilledAnswers & A>;
40 <const A extends Answers, PrefilledAnswers extends Answers = object>(questions: QuestionObservable<A>, answers?: PrefilledAnswers): PromptReturnType<PrefilledAnswers & A>;
41 <const A extends Answers, PrefilledAnswers extends Answers = object>(questions: Question<A>, answers?: PrefilledAnswers): PromptReturnType<PrefilledAnswers & A>;
42 prompts: {
43 [x: string]: LegacyPromptConstructor | PromptFn<any, any>;
44 };
45 /**
46 * Register a prompt type
47 */
48 registerPrompt(name: string, prompt: LegacyPromptConstructor | PromptFn): any;
49 /**
50 * Register the defaults provider prompts
51 */
52 restoreDefaultPrompts(): void;
53 };
54 ui: {
55 Prompt: typeof PromptsRunner;
56 };
57 createPromptModule: typeof createPromptModule;
58 registerPrompt: typeof registerPrompt;
59 restoreDefaultPrompts: typeof restoreDefaultPrompts;
60 Separator: typeof Separator;
61};
62export default inquirer;