Skip to content

Commit

Permalink
Fix(inquirer): Handle choices without value property (backward compat…
Browse files Browse the repository at this point in the history
… with v9)

Fixes #1482
  • Loading branch information
SBoudrias committed Jul 28, 2024
1 parent 2a40d8a commit 6dfebd9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/inquirer/src/ui/prompt.mts
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,10 @@ export default class PromptsRunner<A extends Answers> {
if ('choices' in question) {
// @ts-expect-error question type is too loose
question.choices = question.choices.map((choice) => {
if (typeof choice === 'string') {
if (typeof choice === 'string' || typeof choice === 'number') {
return { name: choice, value: choice };
} else if (!('value' in choice)) {
return { ...choice, value: choice.name };
}
return choice;
});
Expand Down

0 comments on commit 6dfebd9

Please sign in to comment.