Inquirer.js icon indicating copy to clipboard operation
Inquirer.js copied to clipboard

checkbox type doesn't accept 'loop' option with Typescript

Open Kelmatou opened this issue 4 years ago • 0 comments

Hello!

I'm using Inquirer to let user select one or more choices from a list. Therefore I'm using 'checkbox' type but typescript generates an error:

Type '"checkbox"' is not assignable to type '"number"'.ts(2322)

// doesn't compile
const myQuestion: inquirer.QuestionCollection = {
    type: 'checkbox',
    message: 'make your selection',
    name: 'selection',
    choices: ['Choice1', 'Choice2', 'Choice3'],
    loop: false
}

It seems to only be a type error since replacing the type by any works as expected and doesn't create the type error

// compiles & works (but no typing anymore)
const myQuestion: any = {
    type: 'checkbox',
    message: 'make your selection',
    name: 'selection',
    choices: ['Choice1', 'Choice2', 'Choice3'],
    loop: false
}

Kelmatou avatar Feb 16 '21 16:02 Kelmatou