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

Typescript support?

Open alvinfebriando opened this issue 5 years ago • 4 comments
trafficstars

How to use this library with typescript? It's said no typings were found

alvinfebriando avatar May 08 '20 11:05 alvinfebriando

I think it is possible to use this library with typescript without any modifications.

But I guess the type hinting for the options could be supplied. I am not familiar with typescript, so any suggestion/explanation of how this could work is welcome.

mokkabonna avatar Aug 31 '20 17:08 mokkabonna

For those who need a quick fix until the actual types land, here's what I'm doing:

  • Create _inquirer-autocomplete-prompt.d.ts somewhere reachable from your code, e.g. in src, with this content:
    declare module 'inquirer-autocomplete-prompt'
    
  • Add this line at the beginning of every file where you import autocomplete from 'inquirer-autocomplete-prompt':
    /// <reference path='_inquirer-autocomplete-prompt.d.ts'/>
    
  • Take care of the remaining types locally

I have no errors and the whole thing works.

c-vetter avatar Feb 05 '22 07:02 c-vetter

I will review the PR to help this along. Fixing it is out of scope for now, though, due to other work.

c-vetter avatar Feb 05 '22 07:02 c-vetter

Type definitions are in DefinitelyTyped/inquirer-autocomplete-prompt (project page)

Just need to import @types/inquirer-autocomplete-prompt

jayeeson avatar Jan 08 '23 02:01 jayeeson