@types/inquirer

  • Version 7.3.1
  • Published
  • 70.2 kB
  • 2 dependencies
  • MIT license

Install

npm i @types/inquirer
yarn add @types/inquirer
pnpm add @types/inquirer

Overview

TypeScript definitions for inquirer

Index

Variables

variable inquirer

var inquirer: inquirer.Inquirer;
  • Provides the functionality to prompt questions.

Interfaces

interface AllChoiceMap

interface AllChoiceMap<T extends Answers = Answers> {}
  • Provides all valid choice-types.

    T The type of the answers.

property BaseChoiceMap

BaseChoiceMap: BaseChoiceMap<T>[keyof BaseChoiceMap<T>];

    property CheckboxChoiceMap

    CheckboxChoiceMap: CheckboxChoiceMap<T>[keyof CheckboxChoiceMap<T>];

      property ExpandChoiceMap

      ExpandChoiceMap: ExpandChoiceMap<T>[keyof ExpandChoiceMap<T>];

        property ListChoiceMap

        ListChoiceMap: ListChoiceMap<T>[keyof ListChoiceMap<T>];

          interface Answers

          interface Answers extends Record<string, any> {}
          • A set of answers.

          interface BaseChoiceMap

          interface BaseChoiceMap<T extends Answers = Answers> {}
          • Provides all valid choice-types for any kind of question.

            T The type of the answers.

          property Choice

          Choice: Choice<T>;

            property ChoiceOptions

            ChoiceOptions: ChoiceOptions<T>;

              property Separator

              Separator: Separator;

                property SeparatorOptions

                SeparatorOptions: SeparatorOptions;

                  interface CheckboxChoiceMap

                  interface CheckboxChoiceMap<T extends Answers = Answers> extends BaseChoiceMap<T> {}
                  • Provides all valid choice-types for the CheckboxQuestion.

                    T The type of the answers.

                  property CheckboxChoiceOptions

                  CheckboxChoiceOptions: CheckboxChoiceOptions<T>;

                    interface CheckboxChoiceOptions

                    interface CheckboxChoiceOptions<T extends Answers = Answers>
                    extends ListChoiceOptions<T> {}
                    • Provides options for a choice of the CheckboxPrompt.

                      T The type of the answers.

                    property checked

                    checked?: boolean;
                    • A value indicating whether the choice should be initially checked.

                    interface CheckboxQuestion

                    interface CheckboxQuestion<T extends Answers = Answers>
                    extends CheckboxQuestionOptions<T> {}
                    • Provides options for a question for the CheckboxPrompt.

                      T The type of the answers.

                    property type

                    type: 'checkbox';

                    interface CheckboxQuestionOptions

                    interface CheckboxQuestionOptions<T extends Answers = Answers>
                    extends ListQuestionOptionsBase<T, CheckboxChoiceMap<T>> {}
                    • Provides options for a question for the CheckboxPrompt.

                      T The type of the answers.

                    interface ChoiceBase

                    interface ChoiceBase {}
                    • Represents a choice-item.

                    property type

                    type?: string;
                    • The type of the choice.

                    interface ChoiceOptions

                    interface ChoiceOptions<T extends Answers = Answers> extends ChoiceBase {}
                    • Provides options for a choice.

                      T The type of the answers.

                    property extra

                    extra?: any;
                    • The extra properties of the choice.

                    property name

                    name?: string;
                    • The name of the choice to show to the user.

                    property short

                    short?: string;
                    • The short form of the name of the choice.

                    property type

                    type?: 'choice';

                    property value

                    value?: any;
                    • The value of the choice.

                    interface ConfirmQuestion

                    interface ConfirmQuestion<T extends Answers = Answers>
                    extends ConfirmQuestionOptions<T> {}
                    • Provides options for a question for the ConfirmPrompt.

                      T The type of the answers.

                    property type

                    type: 'confirm';

                    interface ConfirmQuestionOptions

                    interface ConfirmQuestionOptions<T extends Answers = Answers> extends Question<T> {}
                    • Provides options for a question for the ConfirmPrompt.

                      T The type of the answers.

                    interface EditorQuestion

                    interface EditorQuestion<T extends Answers = Answers>
                    extends EditorQuestionOptions<T> {}
                    • Provides options for a question for the EditorPrompt.

                      T The type of the answers.

                    property type

                    type: 'editor';

                    interface EditorQuestionOptions

                    interface EditorQuestionOptions<T extends Answers = Answers> extends Question<T> {}
                    • Provides options for a question for the EditorPrompt.

                      T The type of the answers.

                    interface ExpandChoiceMap

                    interface ExpandChoiceMap<T extends Answers = Answers> extends BaseChoiceMap<T> {}
                    • Provides all valid choice-types for the ExpandQuestion.

                      T The type of the answers.

                    property ExpandChoiceOptions

                    ExpandChoiceOptions: ExpandChoiceOptions<T>;

                      interface ExpandChoiceOptions

                      interface ExpandChoiceOptions<T extends Answers = Answers>
                      extends ChoiceOptions<T> {}
                      • Provides options for a choice of the ExpandPrompt.

                        T The type of the answers.

                      property key

                      key?: string;
                      • The key to press for selecting the choice.

                      interface ExpandQuestion

                      interface ExpandQuestion<T extends Answers = Answers>
                      extends ExpandQuestionOptions<T> {}
                      • Provides options for a question for the ExpandPrompt.

                        T The type of the answers.

                      property type

                      type: 'expand';

                      interface ExpandQuestionOptions

                      interface ExpandQuestionOptions<T extends Answers = Answers>
                      extends ListQuestionOptionsBase<T, ExpandChoiceMap<T>> {}
                      • Provides options for a question for the ExpandPrompt.

                        T The type of the answers.

                      interface InputQuestion

                      interface InputQuestion<T extends Answers = Answers>
                      extends InputQuestionOptions<T> {}
                      • Provides options for a question for the InputPrompt.

                        T The type of the answers.

                      property type

                      type?: 'input';

                      interface InputQuestionOptions

                      interface InputQuestionOptions<T extends Answers = Answers> extends Question<T> {}
                      • Provides options for a question for the InputPrompt.

                        T The type of the answers.

                      method transformer

                      transformer: (
                      input: any,
                      answers: T,
                      flags: { isFinal?: boolean }
                      ) => string | Promise<string>;
                      • Transforms the value to display to the user.

                        Parameter input

                        The input provided by the user.

                        Parameter answers

                        The answers provided by the users.

                        Parameter flags

                        Additional information about the value.

                        Returns

                        The value to display to the user.

                      interface Inquirer

                      interface Inquirer extends PromptModuleBase {}

                        property prompt

                        prompt: PromptModule;
                        • The default prompt-module.

                        property prompts

                        prompts: {};
                        • The prompts of the default prompt-module.

                          Deprecated

                        property Separator

                        Separator: typeof Separator;
                        • Represents a choice-item separator.

                        property ui

                        ui: {
                        /**
                        * Represents the bottom-bar UI.
                        */
                        BottomBar: typeof BottomBar;
                        /**
                        * Represents the prompt ui.
                        */
                        Prompt: typeof PromptUI;
                        };
                        • Provides ui-components.

                        method createPromptModule

                        createPromptModule: (opt?: StreamOptions) => PromptModule;
                        • Creates a prompt-module.

                          Parameter opt

                          The streams for the prompt-module.

                          Returns

                          The new prompt-module.

                        method registerPrompt

                        registerPrompt: (name: string, prompt: prompts.PromptConstructor) => void;
                        • Registers a new prompt-type.

                          Parameter name

                          The name of the prompt.

                          Parameter prompt

                          The constructor of the prompt.

                        interface ListChoiceMap

                        interface ListChoiceMap<T extends Answers = Answers> extends BaseChoiceMap<T> {}
                        • Provides all valid choice-types for the ListQuestion.

                          T The type of the answers.

                        property ListChoiceOptions

                        ListChoiceOptions: ListChoiceOptions<T>;

                          interface ListChoiceOptions

                          interface ListChoiceOptions<T extends Answers = Answers> extends ChoiceOptions<T> {}
                          • Provides options for a choice of the ListPrompt.

                            T The type of the answers.

                          property disabled

                          disabled?: DynamicQuestionProperty<boolean | string, T>;
                          • A value indicating whether the choice is disabled.

                          interface ListQuestion

                          interface ListQuestion<T extends Answers = Answers> extends ListQuestionOptions<T> {}
                          • Provides options for a question for the ListPrompt.

                            T The type of the answers.

                          property type

                          type: 'list';

                          interface ListQuestionOptions

                          interface ListQuestionOptions<T extends Answers = Answers>
                          extends ListQuestionOptionsBase<T, ListChoiceMap<T>> {}
                          • Provides options for a question for the ListPrompt.

                            T The type of the answers.

                          property loop

                          loop?: boolean;
                          • A value indicating whether choices in a list should be looped.

                          interface NumberQuestion

                          interface NumberQuestion<T extends Answers = Answers>
                          extends NumberQuestionOptions<T> {}
                          • Provides options for a question for the NumberPrompt.

                            T The type of the answers.

                          property type

                          type: 'number';

                          interface NumberQuestionOptions

                          interface NumberQuestionOptions<T extends Answers = Answers>
                          extends InputQuestionOptions<T> {}
                          • Provides options for a question for the NumberPrompt.

                            T The type of the answers.

                          interface PasswordQuestion

                          interface PasswordQuestion<T extends Answers = Answers>
                          extends PasswordQuestionOptions<T> {}
                          • Provides options for a question for the PasswordPrompt.

                            T The type of the answers.

                          property type

                          type: 'password';

                          interface PasswordQuestionOptions

                          interface PasswordQuestionOptions<T extends Answers = Answers>
                          extends InputQuestionOptions<T> {}
                          • Provides options for a question for the PasswordPrompt.

                            T The type of the answers.

                          property mask

                          mask?: string;
                          • The character to replace the user-input.

                          interface PromptModule

                          interface PromptModule extends PromptModuleBase {}
                          • Provides the functionality to prompt questions to the user.

                          property prompts

                          prompts: prompts.PromptCollection;
                          • The prompts of the prompt-module.

                          method registerPrompt

                          registerPrompt: (name: string, prompt: prompts.PromptConstructor) => this;
                          • Registers a new prompt-type.

                            Parameter name

                            The name of the prompt.

                            Parameter prompt

                            The constructor of the prompt.

                          call signature

                          <T>(
                          questions: QuestionCollection<T>,
                          initialAnswers?: Partial<T>
                          ): Promise<T> & { ui: PromptUI };
                          • Prompts the questions to the user.

                          interface Question

                          interface Question<T extends Answers = Answers> {}
                          • Provides options for a question.

                            T The type of the answers.

                          property default

                          default?: AsyncDynamicQuestionProperty<any, T>;
                          • The default value of the question.

                          property message

                          message?: AsyncDynamicQuestionProperty<string, T>;
                          • The message to show to the user.

                          property name

                          name?: KeyUnion<T>;
                          • The key to save the answer to the answers-hash.

                          property prefix

                          prefix?: string;
                          • The prefix of the message.

                          property suffix

                          suffix?: string;
                          • The suffix of the message.

                          property type

                          type?: string;
                          • The type of the question.

                          property when

                          when?: AsyncDynamicQuestionProperty<boolean, T>;
                          • A value indicating whether the question should be prompted.

                          method filter

                          filter: (input: any, answers: T) => any;
                          • Post-processes the answer.

                            Parameter input

                            The answer provided by the user.

                            Parameter answers

                            The answers provided by the user.

                          method validate

                          validate: (
                          input: any,
                          answers?: T
                          ) => boolean | string | Promise<boolean | string>;
                          • Validates the integrity of the answer.

                            Parameter input

                            The answer provided by the user.

                            Parameter answers

                            The answers provided by the user.

                            Returns

                            Either a value indicating whether the answer is valid or a string which describes the error.

                          interface QuestionMap

                          interface QuestionMap<T extends Answers = Answers> {}
                          • Provides the available question-types.

                            T The type of the answers.

                          property checkbox

                          checkbox: CheckboxQuestion<T>;
                          • The CheckboxQuestion type.

                          property confirm

                          confirm: ConfirmQuestion<T>;
                          • The ConfirmQuestion type.

                          property editor

                          editor: EditorQuestion<T>;
                          • The EditorQuestion type.

                          property expand

                          expand: ExpandQuestion<T>;
                          • The ExpandQuestion type.

                          property input

                          input: InputQuestion<T>;
                          • The InputQuestion type.

                          property list

                          list: ListQuestion<T>;
                          • The ListQuestion type.

                          property number

                          number: NumberQuestion<T>;
                          • The NumberQuestion type.

                          property password

                          password: PasswordQuestion<T>;
                          • The PasswordQuestion type.

                          property rawList

                          rawList: RawListQuestion<T>;
                          • The RawListQuestion type.

                          interface RawListQuestion

                          interface RawListQuestion<T extends Answers = Answers>
                          extends RawListQuestionOptions<T> {}
                          • Provides options for a question for the RawListPrompt.

                            T The type of the answers.

                          property type

                          type: 'rawlist';

                          interface RawListQuestionOptions

                          interface RawListQuestionOptions<T extends Answers = Answers>
                          extends ListQuestionOptions<T> {}
                          • Provides options for a question for the RawListPrompt.

                            T The type of the answers.

                          interface SeparatorOptions

                          interface SeparatorOptions {}
                          • Represents a separator.

                          property line

                          line?: string;
                          • Gets or sets the text of the separator.

                          property type

                          type: 'separator';
                          • Gets the type of the choice.

                          interface StreamOptions

                          interface StreamOptions {}
                          • Provides an input and an output-stream.

                          property input

                          input?: NodeJS.ReadStream;
                          • A stream to read the input from.

                          property output

                          output?: NodeJS.WriteStream;
                          • A stream to write the output to.

                          Type Aliases

                          type AsyncDynamicQuestionProperty

                          type AsyncDynamicQuestionProperty<
                          T,
                          TAnswers extends Answers = Answers
                          > = DynamicQuestionProperty<T | Promise<T>, TAnswers>;
                          • Represents a dynamic property for a question which can be fetched asynchronously.

                          type ChoiceCollection

                          type ChoiceCollection<T extends Answers = Answers> = Array<
                          DistinctChoice<AllChoiceMap>
                          >;
                          • Represents a set of choices.

                          type DistinctChoice

                          type DistinctChoice<TChoiceMap> = string | TChoiceMap[keyof TChoiceMap];
                          • Provides valid choices for the question of the TChoiceMap.

                            TChoiceMap The choice-types to provide.

                          type DistinctQuestion

                          type DistinctQuestion<
                          T extends Answers = Answers
                          > = QuestionMap<T>[keyof QuestionMap<T>];
                          • Represents one of the available questions.

                            T The type of the answers.

                          type DynamicQuestionProperty

                          type DynamicQuestionProperty<T, TAnswers extends Answers = Answers> =
                          | T
                          | ((answers: TAnswers) => T);
                          • Represents a dynamic property for a question.

                          type KeyUnion

                          type KeyUnion<T> = LiteralUnion<Extract<keyof T, string>>;
                          • Represents either a key of T or a string.

                            T The type of the keys to suggest.

                          type QuestionCollection

                          type QuestionCollection<T extends Answers = Answers> =
                          | DistinctQuestion<T>
                          | ReadonlyArray<DistinctQuestion<T>>
                          | Observable<DistinctQuestion<T>>;
                          • Represents a collection of questions.

                            T The type of the answers.

                          type QuestionTypeName

                          type QuestionTypeName = DistinctQuestion['type'];
                          • Indicates the type of a question

                          type Transformer

                          type Transformer<
                          T extends Answers = Answers
                          > = InputQuestionOptions<T>['transformer'];
                          • Provides the functionality to transform an answer.

                            T The type of the answers.

                          type UnionToIntersection

                          type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
                          k: infer I
                          ) => void
                          ? I
                          : never;
                          • Converts the specified union-type U to an intersection-type.

                            U The union to convert to an intersection.

                          type Validator

                          type Validator<T extends Answers = Answers> = Question<T>['validate'];
                          • Provides the functionality to validate answers.

                            T The type of the answers.

                          Namespaces

                          namespace prompts

                          namespace prompts {}
                          • Provides components for the prompts.

                          interface FailedPromptStateData

                          interface FailedPromptStateData extends PromptStateData {}
                          • Provides data about the failed state of a prompt.

                          property isValid

                          isValid: false | string;

                          interface PromptBase

                          interface PromptBase {}
                          • Represents a prompt.

                          property status

                          status: PromptState;
                          • Gets or sets a string which represents the state of the prompt.

                          method run

                          run: () => Promise<any>;
                          • Runs the prompt.

                            Returns

                            The result of the prompt.

                          interface PromptConstructor

                          interface PromptConstructor {}
                          • Provides the functionality to initialize new prompts.

                          construct signature

                          new (question: any, readLine: ReadlineInterface, answers: Answers): PromptBase;
                          • Initializes a new instance of a prompt.

                            Parameter question

                            The question to prompt.

                            Parameter readLine

                            An object for reading from the command-line.

                            Parameter answers

                            The answers provided by the user.

                          interface PromptEventPipes

                          interface PromptEventPipes<T = any> {}
                          • Provides pipes for handling events of a prompt.

                            Parameter T

                            The type of the answer.

                          property error

                          error: Observable<FailedPromptStateData>;
                          • An object representing an error.

                          property success

                          success: Observable<SuccessfulPromptStateData<T>>;
                          • A pypeline for succesful inputs.

                          interface PromptStateData

                          interface PromptStateData {}
                          • Provides data about the state of a prompt.

                          property isValid

                          isValid: string | boolean;
                          • Either a string which describes the error of the prompt or a boolean indicating whether the prompt-value is valid.

                          interface SuccessfulPromptStateData

                          interface SuccessfulPromptStateData<T = any> extends PromptStateData {}
                          • Provides data about the successful state of a prompt.

                            Parameter T

                            The type of the answer.

                          property isValid

                          isValid: true;

                          property value

                          value: T;
                          • The value of the prompt.

                          type PromptCollection

                          type PromptCollection = Record<string, PromptConstructor>;
                          • Provides a set of prompt-constructors.

                          type PromptOptions

                          type PromptOptions<T extends Question = Question> = T & {
                          /**
                          * The choices of the prompt.
                          */
                          choices: Choices;
                          };
                          • Provides a base for and prompt-options.

                            T The type of the answers.

                          type PromptState

                          type PromptState = LiteralUnion<
                          'pending' | 'idle' | 'loading' | 'answered' | 'done'
                          >;
                          • Represents the state of a prompt.

                          namespace ui

                          namespace ui {}
                          • Provides components for the ui.

                          interface BottomBarOptions

                          interface BottomBarOptions extends StreamOptions {}
                          • Provides options for the bottom-bar UI.

                          property bottomBar

                          bottomBar?: string;
                          • The initial text to display.

                          interface FetchedAnswer

                          interface FetchedAnswer {}
                          • Represents a fetched answer.

                          property answer

                          answer: any;
                          • The value of the answer.

                          property name

                          name: string;
                          • The name of the answer.

                          type FetchedQuestion

                          type FetchedQuestion<T extends Answers = Answers> = DistinctQuestion<T> & {
                          /**
                          * The type of the question.
                          */
                          type: string;
                          /**
                          * The message to show to the user.
                          */
                          message: string;
                          /**
                          * The default value of the question.
                          */
                          default: any;
                          /**
                          * The choices of the question.
                          */
                          choices: ChoiceCollection<T>;
                          };
                          • Represents a fetched answer.

                            T The type of the answers.

                          Package Files (1)

                          Dependencies (2)

                          Dev Dependencies (0)

                          No dev dependencies.

                          Peer Dependencies (0)

                          No peer dependencies.

                          Badge

                          To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                          You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/inquirer.

                          • Markdown
                            [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/inquirer)
                          • HTML
                            <a href="https://www.jsdocs.io/package/@types/inquirer"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>