From 0d03d708ef1e48d501cd88becb56ac7195edb934 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20G=C5=82owala?= <48835293+DamianGlowala@users.noreply.github.com> Date: Tue, 27 Jun 2023 00:36:33 +0200 Subject: [PATCH] fix: correct and improve return types for single and multi select prompts (#197) --- src/prompt.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/prompt.ts b/src/prompt.ts index ad6e784..f854614 100644 --- a/src/prompt.ts +++ b/src/prompt.ts @@ -21,7 +21,7 @@ export type ConfirmOptions = { export type SelectOptions = { type: "select"; initial?: string; - options: (SelectOption | string)[]; + options: (string | SelectOption)[]; }; export type MultiSelectOptions = { @@ -41,7 +41,11 @@ type inferPromptReturnType = T extends TextOptions ? string : T extends ConfirmOptions ? boolean - : string[]; + : T extends SelectOptions + ? T["options"][number] + : T extends MultiSelectOptions + ? T["options"] + : unknown; export async function prompt< _ = any,