@types/inquirer
- Version 9.0.7
- Published
- 73.6 kB
- 2 dependencies
- MIT license
Install
npm i @types/inquirer
yarn add @types/inquirer
pnpm add @types/inquirer
Overview
TypeScript definitions for inquirer
Index
Functions
Interfaces
Type Aliases
Namespaces
Functions
function createPromptModule
createPromptModule: (opt?: StreamOptions) => PromptModule;
Creates a prompt-module.
Parameter opt
The streams for the prompt-module.
Returns
The new prompt-module.
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;
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 .
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 .
T The type of the answers.
property checked
checked?: boolean | undefined;
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 .
T The type of the answers.
property type
type: 'checkbox';
interface CheckboxQuestionOptions
interface CheckboxQuestionOptions<T extends Answers = Answers> extends LoopableListQuestionOptionsBase<T, CheckboxChoiceMap<T>> {}
Provides options for a question for the .
T The type of the answers.
interface ChoiceBase
interface ChoiceBase {}
Represents a choice-item.
property type
type?: string | undefined;
The type of the choice.
interface ChoiceOptions
interface ChoiceOptions extends ChoiceBase {}
Provides options for a choice.
property extra
extra?: any;
The extra properties of the choice.
property name
name?: string | undefined;
The name of the choice to show to the user.
property short
short?: string | undefined;
The short form of the name of the choice.
property type
type?: 'choice' | undefined;
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 .
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 .
T The type of the answers.
interface EditorQuestion
interface EditorQuestion<T extends Answers = Answers> extends EditorQuestionOptions<T> {}
Provides options for a question for the .
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 .
T The type of the answers.
property postfix
postfix?: string;
The postfix of the file being edited.
Adding this will add color highlighting to the file content in most editors.
interface ExpandChoiceMap
interface ExpandChoiceMap<T extends Answers = Answers> extends BaseChoiceMap<T> {}
Provides all valid choice-types for the .
T The type of the answers.
property ExpandChoiceOptions
ExpandChoiceOptions: ExpandChoiceOptions;
interface ExpandChoiceOptions
interface ExpandChoiceOptions extends ChoiceOptions {}
Provides options for a choice of the .
property key
key?: string | undefined;
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 .
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 .
T The type of the answers.
interface InputQuestion
interface InputQuestion<T extends Answers = Answers> extends InputQuestionOptions<T> {}
Provides options for a question for the .
T The type of the answers.
property type
type?: 'input' | undefined;
interface InputQuestionOptions
interface InputQuestionOptions<T extends Answers = Answers> extends Question<T> {}
Provides options for a question for the .
T The type of the answers.
method transformer
transformer: ( input: any, answers: T, flags: { isFinal?: boolean | undefined }) => 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 ListChoiceMap
interface ListChoiceMap<T extends Answers = Answers> extends BaseChoiceMap<T> {}
Provides all valid choice-types for the .
T The type of the answers.
property ListChoiceOptions
ListChoiceOptions: ListChoiceOptions<T>;
interface ListChoiceOptions
interface ListChoiceOptions<T extends Answers = Answers> extends ChoiceOptions {}
Provides options for a choice of the .
T The type of the answers.
property disabled
disabled?: DynamicQuestionProperty<boolean | string, T> | undefined;
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 .
T The type of the answers.
property type
type: 'list';
interface ListQuestionOptions
interface ListQuestionOptions<T extends Answers = Answers> extends LoopableListQuestionOptionsBase<T, ListChoiceMap<T>> {}
Provides options for a question for the .
T The type of the answers.
interface NumberQuestion
interface NumberQuestion<T extends Answers = Answers> extends NumberQuestionOptions<T> {}
Provides options for a question for the .
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 .
T The type of the answers.
interface PasswordQuestion
interface PasswordQuestion<T extends Answers = Answers> extends PasswordQuestionOptions<T> {}
Provides options for a question for the .
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 .
T The type of the answers.
property mask
mask?: string | undefined;
The character to replace the user-input.
interface PromptFunction
interface PromptFunction {}
Represents a function for prompting questions to the user.
call signature
<T extends Answers = Answers>( questions: QuestionCollection<T>, initialAnswers?: Partial<T>): Promise<T>;
Prompts the questions to the user.
interface PromptModule
interface PromptModule extends PromptModuleBase {}
Provides the functionality to prompt questions to the user.
property prompts
prompts: inquirer.prompts.PromptCollection;
The prompts of the prompt-module.
method registerPrompt
registerPrompt: ( name: string, prompt: inquirer.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 extends Answers = Answers>( questions: QuestionCollection<T>, initialAnswers?: Partial<T>): Promise<T> & { ui: inquirer.ui.Prompt<T> };
Prompts the questions to the user.
interface PromptModuleBase
interface PromptModuleBase extends PromptFunction {}
Provides prompts for answering questions.
method registerPrompt
registerPrompt: ( name: string, prompt: inquirer.prompts.PromptConstructor) => void;
Registers a new prompt-type.
Parameter name
The name of the prompt.
Parameter prompt
The constructor of the prompt.
method restoreDefaultPrompts
restoreDefaultPrompts: () => void;
Registers the default prompts.
interface Question
interface Question<T extends Answers = Answers> {}
Provides options for a question.
T The type of the answers.
property askAnswered
askAnswered?: boolean;
Force to prompt the question if the answer already exists.
property default
default?: AsyncDynamicQuestionProperty<any, T> | undefined;
The default value of the question.
property message
message?: AsyncDynamicQuestionProperty<string, T> | undefined;
The message to show to the user.
property name
name?: KeyUnion<T> | undefined;
The key to save the answer to the answers-hash.
property prefix
prefix?: string | undefined;
The prefix of the .
property suffix
suffix?: string | undefined;
The suffix of the .
property type
type?: string | undefined;
The type of the question.
property when
when?: AsyncDynamicQuestionProperty<boolean, T> | undefined;
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 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 type.
property confirm
confirm: ConfirmQuestion<T>;
The type.
property editor
editor: EditorQuestion<T>;
The type.
property expand
expand: ExpandQuestion<T>;
The type.
property input
input: InputQuestion<T>;
The type.
property list
list: ListQuestion<T>;
The type.
property number
number: NumberQuestion<T>;
The type.
property password
password: PasswordQuestion<T>;
The type.
property rawList
rawList: RawListQuestion<T>;
The type.
interface RawListQuestion
interface RawListQuestion<T extends Answers = Answers> extends RawListQuestionOptions<T> {}
Provides options for a question for the .
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 .
T The type of the answers.
interface SeparatorOptions
interface SeparatorOptions extends ChoiceBase {}
Represents a separator.
interface StreamOptions
interface StreamOptions {}
Provides an input and an output-stream.
property input
input?: NodeJS.ReadStream | undefined;
A stream to read the input from.
property output
output?: NodeJS.WriteStream | undefined;
A stream to write the output to.
property skipTTYChecks
skipTTYChecks?: boolean | undefined;
Whether to display prompts if input is not a TTY.
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.
T The type of the property.
TAnswers The type of the answers.
type ChoiceCollection
type ChoiceCollection<T extends Answers = Answers> = Array< DistinctChoice<T, AllChoiceMap<T>>>;
Represents a set of choices.
T The type of the answers.
type DistinctChoice
type DistinctChoice< TAnswers extends Answers = Answers, TChoiceMap = AllChoiceMap<TAnswers>> = string | TChoiceMap[keyof TChoiceMap];
Provides valid choices for the question of the .
TAnswers The type of the answers.
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.
T The type of the property.
TAnswers The type of the answers.
type KeyUnion
type KeyUnion<T> = LiteralUnion<Extract<keyof T, string>>;
Represents either a key of or a .
T The type of the keys to suggest.
type QuestionAnswer
type QuestionAnswer<T extends Answers = Answers> = { [K in keyof T]: { name: K; answer: T[K]; };}[keyof T];
Represents the possible answers of each question in the prompt
type QuestionCollection
type QuestionCollection<T extends Answers = Answers> = | DistinctQuestion<T> | ReadonlyArray<DistinctQuestion<T>> | Observable<DistinctQuestion<T>> | { [P in KeyUnion<T>]?: DistinctQuestion<T> & { name?: never } };
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 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 inquirer
namespace inquirer {}
Provides the functionality to prompt questions.
variable createPromptModule
let createPromptModule: (opt?: StreamOptions) => PromptModule;
Creates a prompt-module.
Parameter opt
The streams for the prompt-module.
Returns
The new prompt-module.
variable prompt
let prompt: PromptModule;
The default prompt-module.
variable registerPrompt
let 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.
variable restoreDefaultPrompts
let restoreDefaultPrompts: () => void;
Registers the default prompts.
class Separator
class Separator implements SeparatorOptions {}
Represents a choice-item separator.
constructor
constructor(line?: string);
Initializes a new instance of the class.
Parameter line
The text of the separator.
property line
line: string;
property type
readonly type: string;
method exclude
static exclude: (item: any) => boolean;
Checks whether the specified is not a separator.
Parameter item
The item to check.
Returns
A value indicating whether the item is not a separator.
namespace inquirer.prompts
namespace inquirer.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.
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.
interface PromptStateData
interface PromptStateData {}
Provides data about the state of a prompt.
property isValid
isValid: string | boolean;
Either a which describes the error of the prompt or a 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.
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 options for a prompt.
T The type of the answers.
type PromptState
type PromptState = LiteralUnion< 'pending' | 'idle' | 'loading' | 'answered' | 'done'>;
Represents the state of a prompt.
namespace inquirer.ui
namespace inquirer.ui {}
Provides components for the ui.
class BottomBar
class BottomBar extends UI {}
Represents the bottom-bar UI.
constructor
constructor(options?: BottomBarOptions);
Initializes a new instance of the class.
Parameter options
Provides options for the bottom-bar ui.
property log
log: ThroughStream;
Gets or sets a stream to write logs to.
method clean
protected clean: () => this;
Cleans the bottom bar.
method enforceLF
protected enforceLF: (text: string) => string;
Fixes the new-line characters of the specified .
Parameter text
The text to process.
method render
protected render: () => this;
Renders the bottom bar.
method updateBottomBar
updateBottomBar: (text: string) => this;
Renders the specified to the bottom bar.
Parameter text
The text to print to the bottom bar.
method write
protected write: (message: string) => void;
Writes a message to the bottom bar.
Parameter message
The message to write.
method writeLog
protected writeLog: (data: any) => this;
Writes the specified to the log-zone.
Parameter data
The data to write to the log-zone.
class Prompt
class Prompt<T extends Answers = Answers> extends UI {}
Represents the prompt ui.
constructor
constructor(prompts: prompts.PromptCollection, options?: StreamOptions);
Initializes a new instance of the class.
Parameter prompts
The prompts for the ui.
Parameter options
The input- and output-stream of the ui.
property answers
answers: Answers;
Gets or sets the answers provided by the user.
property process
process: Observable<QuestionAnswer<T>>;
Gets or sets the event-flow of the process.
property prompts
prompts: prompts.PromptCollection;
Gets or sets the prompts of the ui.
method fetchAnswer
protected fetchAnswer: ( question: FetchedQuestion<T>) => Observable<FetchedAnswer>;
Fetches the answer to a question.
Parameter question
The question to fetch the answer for.
Returns
The answer to the question.
method filterIfRunnable
protected filterIfRunnable: ( question: DistinctQuestion<T>) => Observable<DistinctQuestion<T>>;
Filters the question if it is runnable.
Parameter question
The question to filter.
Returns
Either the event-flow of the question if it is runnable or an empty event-flow.
method onCompletion
protected onCompletion: () => T;
Finishes the process.
method processQuestion
protected processQuestion: ( question: DistinctQuestion<T>) => Observable<FetchedAnswer>;
Processes a question.
Parameter question
The question to process.
Returns
The answer to the question.
method run
run: (questions: Array<DistinctQuestion<T>>) => Promise<T>;
Runs the prompt-UI.
Parameter questions
The questions to prompt the user to answer.
Returns
The answers provided by the user.
method setDefaultType
protected setDefaultType: ( question: DistinctQuestion<T>) => Observable<DistinctQuestion<T>>;
Sets the type of the question if no question-type is specified.
Parameter question
The question to set the default type for.
Returns
The processed question.
interface BottomBarOptions
interface BottomBarOptions extends StreamOptions {}
Provides options for the bottom-bar UI.
property bottomBar
bottomBar?: string | undefined;
The initial text to display.
interface FetchedAnswer
interface FetchedAnswer {}
Represents a fetched 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 oneto 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>
- Updated .
Package analyzed in 5646 ms. - Missing or incorrect documentation? Open an issue for this package.