-
-
Notifications
You must be signed in to change notification settings - Fork 290
Closed
Description
In autocomplete I'm loading a list of SPDX License Identifiers as an array. If I type bsd-
then type 2
it throws this error.
I searched this issue to see if anyone else and came across a issue report with another tool using the same library Automattic/vip-cli#265 on trying to type test-0
. So sounds like a very similar issue possibly causing both.
I'm using Typescript but isolated the part with the issue to test standalone:
import enquirer from 'enquirer';
import licenseIDs from 'spdx-license-list/simple';
const licenseIDArray = Array.from(licenseIDs);
async function test() {
const promptObject = {
type: 'autocomplete',
name: 'value',
message: 'Enter a SPDX License Identifier - https://spdx.org/licenses/',
// @ts-ignore: this works, I believe error is due to lack of typing information
// tslint:disable-next-line: no-any
suggest(input: { toLowerCase: () => void }, choices: { filter: (arg0: (choice: { message: { toLowerCase: () => { startsWith: (arg0: any) => void } } }) => void) => void }) {
// tslint:disable-next-line: no-any
return choices.filter(function (choice: { message: { toLowerCase: () => { startsWith: (arg0: any) => void } } }) { return choice.message.toLowerCase().startsWith(input.toLowerCase()); });
},
limit: 10,
choices: licenseIDArray
};
const response = await enquirer.prompt(promptObject);
console.log(response);
}
void test();
Here's the error
? Enter a SPDX License Identifier - https://spdx.org/licenses/ … bsd-(node:35300) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'enabled' of undefined
at number (/demo/node_modules/enquirer/lib/types/array.js:276:19)
at handle (/demo/node_modules/enquirer/lib/types/array.js:307:18)
at resolve (/demo/node_modules/enquirer/lib/types/array.js:313:16)
at new Promise (<anonymous>)
at AutoComplete.number (/demo/node_modules/enquirer/lib/types/array.js:301:12)
at AutoComplete.keypress (/demo/node_modules/enquirer/lib/prompt.js:44:17)
at ReadStream.on (/demo/node_modules/enquirer/lib/keypress.js:205:26)
at ReadStream.emit (events.js:194:15)
at emitKeys (internal/readline.js:424:14)
at emitKeys.next (<anonymous>)
(node:35300) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:35300) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Metadata
Metadata
Assignees
Labels
No labels