-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inquirer 10/9 compatibility problems. #1527
Comments
Do you have a full-repro for the |
Ref #1527 ------------ Co-authored-by: Simon Boudrias <[email protected]>
Anoter issue: |
I didn't look too much into it yet, but I think Ref #1540 |
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 I want to make an array of questions which I will later put into an |
@DelliriumX if you want to add your question to types, you can implement like this: Inquirer.js/packages/inquirer/inquirer.test.mts Lines 19 to 26 in 9e29035
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. |
Not exposing question types is still a problem to me. |
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 |
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 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 |
These are not questions, these are plain objects, there is literally 0 type-safety or intelliSense support here. They will give a proper return type when used in context of a prompt, but that would be the case if they were explicitly typed as well. They however will not be "seen" as questions until they are put inside a prompt. This is essentially what I want, to be able to define a
I wont claim to understand the exact types you are using and why this would be the case, but I do not think this is correct, for two reasons:
What i mean by this is: // this works, for all intents and purposes
const answer = await inquirer.prompt([{ name: 'my question', type: 'input' }])
// this code does the same thing, including the inferrence of return type
const question = { name: 'my question', type: 'input' } as const
const answer = await inquirer.prompt([question]) The big difference between the two is that in first case, you get the full typescript support while "writing" your question, in the second case, you are working with a plain object so anything goes... In an ideal world we would be able to: // and the QuestionType would give us the necessary TSC support
const question : QuestionType = { name: 'my question', type: 'input' } as const
const answer = await inquirer.prompt([question])
When you are creating dynamic questions arrays you cannot have it be done In essence do not force us to do this: function prompt(...args: Array<{
title: string,
type: string | number | boolean
}>): void
type ExtractQuestionType = typeof prompt extends (...args: infer R) => any ? R[0] : never
declare const MyQuestion: ExtractQuestionType // now has TS support |
@DelliriumX do you want to send a PR + a test ( |
I'd be willing to assist you, but I'd rather not take charge on this issue since I am not familiar enough with your entire system to feel confident I grasp it well. Not to mention that I am absolutely horrendous when it comes to writing testing... I've got over 15 years of professional experience in this industry and I've not written more than 10 across my entire career. I'd rather avoid that not to f it up. |
|
Issues have been resolved. FYI:
workaround is to inline:
or maybe use satisfies;
|
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:
[email protected]
has a missing type formessage
in prompt function #1495,createPromptModule
typing error : No overload matches this call. The last overload gave the following error.0 #1523promise.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.
The text was updated successfully, but these errors were encountered: