listr2
listr2 copied to clipboard
Upcoming TypeScript changes to Enquirer
I wanted to leave a trace here about a promising PR in the enquirer
repo regarding TypeScript definitions (https://github.com/enquirer/enquirer/pull/307).
I understand that the typings provided by listr2
are an internal reproduction of Enquirer's typings, although they are incomplete. Hopefully once the above PR is merged and published, the custom typings in listr2
can be removed!
Thanks for all the hard work on this great package btw! I love the developer experience here 🚀
Oh that is just great news. I will have a look when the PR gets merged and update accordingly.
Thanks for the heads up and kind words.
Pretty new to the TS world here. Does the above have anything to do with the below?
node_modules/listr2/dist/utils/prompt.interface.d.ts:2:22 - error TS2307: Cannot find module 'enquirer' or its corresponding type declarations.
node_modules/listr2/dist/interfaces/listr.interface.d.ts:2:22 - error TS2307: Cannot find module 'enquirer' or its corresponding type declarations.
Na. This is because I export the prompt.interface.ts from index.ts and since you call the package by index it goes through and parses every import in indivudual files. I import enquirer in prompt.interface.ts for prompt types, so you have to explicitly install enquirer for typescript not going crazy.
You can solve this by installing enquirer as dev dep if you are not going to use it. I am not sure how can fix this shortcoming.
Perfect, needed to enable module interop as well as it was moaning about default imports. Thanks!
Np. Sorry that it is a bit of shortcoming.
I guess this will never get merged to the upstream library.
Another option is to pull those (correct) typings into listr2
and use them directly. I've done this myself in the past: https://github.com/smithki/zombi/blob/master/packages/zombi/src/types/enquirer.ts
Or... maybe it's time for yet another Node.js prompt package. Not a single one has satisfactory TypeScript support in my experience.
Closing this because of being stale and the enquirer receiving no updates. I will add this to looking for contributions section if somebody wants to give it a go.