Open mshima opened 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...
Anoter issue: ui.close()
does not work with modern prompts and there is no alternative.
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.
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 😄)
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.
@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.
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.
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 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
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:
promise.ui.close()
does not work with modern prompts and there is no alternativepromise.ui.rl
is not reliable. Inquirer 9 shared a rl instance for every question in a session. It’s not created for modern questions and a new instance is created for each legacy question. It should be private now.Those issues needs to be addressed for yeoman-environment to officially adopt it.