From 593f93d06c1a53c8424e9aaf0c1c63fbf6975527 Mon Sep 17 00:00:00 2001 From: Bruno Rocha <100330057+Mist3rBru@users.noreply.github.com> Date: Wed, 15 Mar 2023 04:58:47 -0300 Subject: [PATCH] feat: improve group `types` for readability (#105) - Unwrap complex internal types to a top level one - Omit group results current key --- packages/prompts/src/index.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/prompts/src/index.ts b/packages/prompts/src/index.ts index d10f34ce..3b342dd5 100644 --- a/packages/prompts/src/index.ts +++ b/packages/prompts/src/index.ts @@ -654,15 +654,19 @@ export type PromptGroupAwaitedReturn = { export interface PromptGroupOptions { /** - * Control how the group can be canceld - * if one of the prompts is canceld. + * Control how the group can be canceled + * if one of the prompts is canceled. */ - onCancel?: (opts: { results: Partial> }) => void; + onCancel?: (opts: { results: Prettify>> }) => void; } +type Prettify = { + [P in keyof T]: T[P]; +} & {}; + export type PromptGroup = { [P in keyof T]: (opts: { - results: Partial>; + results: Prettify>>>; }) => void | Promise; }; @@ -673,7 +677,7 @@ export type PromptGroup = { export const group = async ( prompts: PromptGroup, opts?: PromptGroupOptions -): Promise> => { +): Promise>> => { const results = {} as any; const promptNames = Object.keys(prompts);