Socket
Socket
Sign inDemoInstall

@types/inquirer

Package Overview
Dependencies
5
Maintainers
1
Versions
58
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/inquirer

TypeScript definitions for inquirer


Version published
Maintainers
1
Weekly downloads
2,453,371
increased by3.26%
Install size
8.26 MB

Weekly downloads

Package description

What is @types/inquirer?

The @types/inquirer package provides TypeScript type definitions for Inquirer.js, a library for creating interactive command-line interfaces. These type definitions enable TypeScript developers to use Inquirer.js with type checking, ensuring that they are using the library's API correctly.

What are @types/inquirer's main functionalities?

Prompt Types

Demonstrates how to use different types of prompts such as 'input' for text input and 'list' for selecting from a list of options.

import inquirer from 'inquirer';

async function askQuestion() {
  const answers = await inquirer.prompt([
    {
      type: 'input',
      name: 'name',
      message: 'What's your name?',
    },
    {
      type: 'list',
      name: 'choice',
      message: 'Pick a choice:',
      choices: ['Choice A', 'Choice B'],
    }
  ]);

  console.log(answers);
}

askQuestion();

Validation

Shows how to validate user input to ensure it meets certain criteria, in this case, checking if the input is a number.

import inquirer from 'inquirer';

inquirer.prompt([
  {
    type: 'input',
    name: 'age',
    message: 'Enter your age:',
    validate: function(value) {
      var valid = !isNaN(parseFloat(value));
      return valid || 'Please enter a number';
    },
    filter: Number,
  }
]).then(answers => {
  console.log(`Your age is ${answers.age}`);
});

Conditional Questions

Illustrates how to ask questions conditionally based on previous answers using the 'when' property.

import inquirer from 'inquirer';

inquirer.prompt([
  {
    type: 'confirm',
    name: 'toBeAsked',
    message: 'Do you want to answer more questions?',
  },
  {
    type: 'input',
    name: 'moreInfo',
    message: 'Tell me more:',
    when: function(answers) {
      return answers.toBeAsked;
    }
  }
]).then(answers => {
  console.log(answers);
});

Other packages similar to @types/inquirer

Readme

Source

Installation

npm install --save @types/inquirer

Summary

This package contains type definitions for inquirer (https://github.com/SBoudrias/Inquirer.js).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/inquirer.

Additional Details

  • Last updated: Tue, 07 Nov 2023 20:08:00 GMT
  • Dependencies: @types/through, rxjs

Credits

These definitions were written by Qubo, Parvez, Jouderian, Qibang, Jason Dreyzehner, Synarque, Justin Rockwood, Keith Kelly, Richard Lea, and Manuel Thalmann.

FAQs

Last updated on 07 Nov 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc