Inquirer.js icon indicating copy to clipboard operation
Inquirer.js copied to clipboard

Transformer bug?

Open paul-uz opened this issue 2 years ago • 5 comments

The docs state

The transformation only impacts what is shown while editing. It does not modify the answers hash.

To me, this reads as that the output in the terminal is "transformed" but the data for the answer is untouched; however this is not the case.

In the pizza.js example, this transformer is set

transformer: (answer: Answers) => (answer ? '👍' : '👎'),

If you log out answer from inquirer.prompt(confirmation).then((answer) => {..., with the transformer in place, its now an emoji. Without the transformer, answer is a bool.

paul-uz avatar Nov 15 '23 15:11 paul-uz

Hi, I think that's because you're reading the documentation of @inquirer/input while using the inquirer package (the depreciated version).

Those packages APIs do not work completely in the same way.

SBoudrias avatar Nov 16 '23 21:11 SBoudrias

Oh right. Can we get some updated docs/examples?

paul-uz avatar Nov 16 '23 22:11 paul-uz

I'm not sure I understand what you need. Each packages have their own docs.

If you're looking for code examples using the new API (@inquirer/prompts, etc), there's a bunch in here https://github.com/SBoudrias/Inquirer.js/tree/master/packages/demo/demos

SBoudrias avatar Nov 17 '23 21:11 SBoudrias

The issue is that the docs for transformer don't match what it actually seems to do, and you mentioned that something was deprecated.

I just want some clear docs.

paul-uz avatar Nov 17 '23 22:11 paul-uz

The docs on confirm are already pretty clear. If you're confused on what exactly the transform property does, you can see the provided example from the link that SBoudrias sent before. If you still think that the docs are unclear, and that they do not match the actual functionality, submit a pull request with your desired changes.

chasemw1 avatar Jan 02 '24 20:01 chasemw1