SBoudrias / Inquirer.js

A collection of common interactive command line user interfaces.
MIT License
20.03k stars 1.3k forks source link

Inquirer 10/9 compatibility problems. #1527

Open mshima opened 2 weeks ago

mshima commented 2 weeks ago

Inquirer 10 is designed to be backward compatible with Inquirer 9. That's great and allows yeoman-generator/environment stack to adopt Inquirer 10.

Problems:

Those issues needs to be addressed for yeoman-environment to officially adopt it.

SBoudrias commented 2 weeks ago

Do you have a full-repro for the message type issue? I don't think it always fail, so I wonder if it's contextual to how the message is passed down somehow...

mshima commented 2 weeks ago

Anoter issue: ui.close() does not work with modern prompts and there is no alternative.

SBoudrias commented 1 week ago

I didn't look too much into it yet, but I think filter might not work at all anymore - not sure when it went (maybe it was initially implemented in prompt classes 😮‍💨). But that'll be a major backward compat issue to fix.

Ref https://github.com/SBoudrias/Inquirer.js/issues/1540

SBoudrias commented 2 days ago

Hey Marcelo, anything that's still a blocker? (I'm not sure how accurate the list in the ticket is after the work we put in this 😄)

DelliriumX commented 1 day ago

I will ride in on this and add, since TS was not supported in v9, we used @types/inquirer. The interfaces that package exported compared to the now TS ready version is very different. Now, i dont mind changing a few things, afterall, it was a major up, but you no longer export types, other than QuestionMap no type is exported from inquirer. How are we suppose to type stuff?

I want to make an array of questions which I will later put into an inquirer.prompt(...my array) what do I do? How do I type my array when the "Question" type is not exported by the package? We used to have DistinctQuestion in @types/, i now find something similar with AnyQuestion but it is not exported.

mshima commented 22 hours ago

@DelliriumX if you want to add your question to types, you can implement like this: https://github.com/SBoudrias/Inquirer.js/blob/9e29035c2efc78f44aed3c7732aee46ab1d64ca2/packages/inquirer/inquirer.test.mts#L19-L26

If you want to wrap inquirer api and expose a customized api like myself, then you need to extract the desired api which will make you rely on unstable interface.

mshima commented 21 hours ago

Hey Marcelo, anything that's still a blocker? (I'm not sure how accurate the list in the ticket is after the work we put in this 😄)

Not exposing question types is still a problem to me. I cannot easily support rxjs questions alternative, we currently only expose array or single question so we can inject data in questions. I am looking to alternative way to implement.

SBoudrias commented 13 hours ago

I'm open to exporting the question type; but note that it prevents inferring the return type. So I'm just unclear in which case that is positive.

Does it not work with const questions = [] as const; or const questions = [{} as const, {} as const, ...]?

DelliriumX commented 9 hours ago

@DelliriumX if you want to add your question to types, you can implement like this:

If you want to wrap inquirer api and expose a customized api like myself, then you need to extract the desired api which will make you rely on unstable interface.

Thing is, i do not, I want to be able to "type" my own object structure that fits a "question" with a type like we used to be able to do prior (v9 it was using the DistinctQuestion type from @types/inquirere). Essentially:

const obj1 = { /* ... */}       // this is untyped and has no intelisense, shape or anything else

inquirer.prompt([
   {
     /* this object literal is recognized as a question and it has all the benefits*/
     /* I want to apply this internal type to my obj1 object*/
    }
])

This is used to be able to construct question prompts dynamically by modifying what is the contents of the array