SBoudrias/Inquirer.js

class constructor error

christoph88 opened this issue · 3 comments

I get following error when trying to run this:

const answer = async () => {
  return await input({ message: "Enter your name" });
};

console.log(answer());

cmd

bun run start
$ bun run index.ts --help
Promise { <pending> }
? Enter your name
120 | 
121 | class AsyncResource {
122 |   type;
123 |   #snapshot;
124 | 
125 |   constructor(type, options) {
                             ^
TypeError: Cannot call a class constructor without |new|
      at AsyncResource (node:async_hooks:125:26)
      at run (/Users/christoph/Code/digital/digital-ai-control-mendable/node_modules/@inquirer/core/dist/esm/lib/hook-engine.mjs:87:13)
      at workLoop (/Users/christoph/Code/digital/digital-ai-control-mendable/node_modules/@inquirer/core/dist/esm/lib/create-prompt.mjs:76:24)
      at /Users/christoph/Code/digital/digital-ai-control-mendable/node_modules/@inquirer/core/dist/esm/lib/create-prompt.mjs:85:20
error: script "start" exited with code 1 (SIGHUP)

This is a bun bug. You can report it over there.

@SBoudrias the issue is in your side.solution is here oven-sh/bun#5997

Confirming that this is a bug in Bun. We are missing the bind function in AsyncResource. Separately, we will add support for calling an AsyncResource