inquirer-autocomplete-prompt
inquirer-autocomplete-prompt copied to clipboard
TypeError: this.line.substring is not a function
It crashes when I tab on "Tab" button for autocomplete. This is how I works with inquirer modules.
await inquirer.prompt([
{
type: "autocomplete",
name: "product",
message: `test`,
suggestOnly: true,
source: function (ans, input) {
return new Promise(async function (res) {
const search = input
? await Product.find({
name: { $regex: new RegExp(input, `i`) },
}).lean()
: [];
const choices = search.map((x) => ({
name: x.name,
value: x,
}));
res(choices);
});
},
},
]);
This error happens when I set value as object to the source
function. Once I changed back the value to string, It works fine.