Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

createPromptModule typing error : No overload matches this call. The last overload gave the following error.0 #1523

Closed
recursivezero opened this issue Aug 27, 2024 · 6 comments

Comments

@recursivezero
Copy link

recursivezero commented Aug 27, 2024

With

  • Nodejs v 22.0
  • inquirer v 10.1.8
  • ubuntu v 24.04
  • typescript v 5.4.5
  • having "type": "module" in package.json
  • file name : /bin/ask.js
import inquirer from "inquirer";

const questions = [
  { type: "input", name: "packageName", message: "tell me package name", default: "template" }];
const prompt = inquirer.createPromptModule();

prompt(questions)
  .then((answers) => {
    // Use user feedback for... whatever!!
    console.log({ answers });
  })
  .catch((error) => {
    if (error.isTtyError) {
      // Prompt couldn't be rendered in the current environment
    } else {
      // Something else went wrong
    }
  });

although it works when run but vs code gives ts lint error as below

No overload matches this call.
  The last overload gave the following error.
    Argument of type '{ type: string; name: string; message: string; default: string; }[]' is not assignable
 to parameter of type 'Readonly<DistributiveMerge<NumberConfig | InputConfig |

{ message: string; choices: readonly (Separator | Choice<unknown>)[]; pageSize?: number | undefined; loop?: 
boolean | undefined; default?: unknown; theme?: { ...; } | undefined; } | ... 5 more ... | EditorConfig, { ...; }>>'.

what is the issue here?

@beakae
Copy link

beakae commented Aug 27, 2024

have had same issue all day

@zigzagoon1
Copy link

Also having this problem. Using node v18.19.0 and TypeScript.

@SBoudrias
Copy link
Owner

SBoudrias commented Aug 30, 2024

Does it work like this?

const questions = [
  { type: "input", name: "packageName", message: "tell me package name", default: "template" }] as const;

I think what happen is you're sending a type that's too liberal to inquirer, and this then prevents any inference of the return type.

The core of the issue with the type you pass in is that type: string; is just invalid. type must be one of a few specific values.

Also, it'll work if you put it inline instead of assigning to a variable:

prompt([
  { type: "input", name: "packageName", message: "tell me package name", default: "template" }
]);

@beakae
Copy link

beakae commented Sep 2, 2024

Does it work like this?

const questions = [
  { type: "input", name: "packageName", message: "tell me package name", default: "template" }] as const;

I think what happen is you're sending a type that's too liberal to inquirer, and this then prevents any inference of the return type.

The core of the issue with the type you pass in is that type: string; is just invalid. type must be one of a few specific values.

Also, it'll work if you put it inline instead of assigning to a variable:

prompt([
  { type: "input", name: "packageName", message: "tell me package name", default: "template" }
]);

Not working for me.

@SBoudrias
Copy link
Owner

... so what's the error with that code?

@SBoudrias
Copy link
Owner

We released new core types today with inquirer@10.2.0. Would appreciate people trying it out and bringing feedback - cheers!

@github-staff github-staff deleted a comment from YeGop0218 Oct 28, 2024
@github-staff github-staff deleted a comment from YeGop0218 Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants