inquirer-autocomplete-prompt icon indicating copy to clipboard operation
inquirer-autocomplete-prompt copied to clipboard

TypeError: this.line.substring is not a function

Open ElvisWong opened this issue 3 years ago • 0 comments

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);
        });
      },
    },
]);

image

This error happens when I set value as object to the source function. Once I changed back the value to string, It works fine.

ElvisWong avatar Jun 08 '21 03:06 ElvisWong