mokkabonna / inquirer-autocomplete-prompt

Autocomplete prompt for inquirer
ISC License
350 stars 82 forks source link

Is it possible to create a typings file for use in Typescript? #61

Closed roybass closed 5 years ago

roybass commented 6 years ago

Please create a typings file so Typescript users could enjoy this package. Thanks :)

pferreir commented 5 years ago

I'm just using this:

declare module "inquirer-autocomplete-prompt" {
    import { PromptModule } from "inquirer";

    let AutocompletePrompt: PromptModule;
    export = AutocompletePrompt;
}
roybass commented 5 years ago

Thanks @pferreir!

CaptainQuirk commented 5 years ago

inquirer-autocomplete-prompt : 1.0.1 typescript: 3.5.3 inquirer: 7.0.0 @types/inquirer: 6.5.0

Hi there @pferreir !

Do you have an example of this in action, please ?

I placed your snippet in a types/inquirer-autocomplete-prompt/index.d.ts file.

I'm trying to register the autocomplete prompt in the following way

import  autocomplete from 'inquirer-autocomplete-prompt'
import { Answers, prompt, Question} from 'inquirer';

export class Test {
    public constructor () {
        prompt.registerPrompt('autocomplete', autocomplete)
    }
}

I get the following error :

 error TS2345: Argument of type 'PromptModule' is not assignable to parameter of type 'PromptConstructor'.
  Type 'PromptModule' provides no match for the signature 'new (question: any, readLine: Interface, answers: Answers): PromptBase'.

Edit

This plugin only supports Inquirer version 5.x. The @types/inquirer definition started with 6.0.0. @mokkabonna do you have plans to update this plugin ?

Thanks in advance !