Skip to content

Commit

Permalink
chore: add prettify type helper
Browse files Browse the repository at this point in the history
  • Loading branch information
Mist3rBru committed Mar 9, 2023
1 parent f44c104 commit ac7d1e1
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/prompts/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -654,15 +654,19 @@ export type PromptGroupAwaitedReturn<T> = {

export interface PromptGroupOptions<T> {
/**
* 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<PromptGroupAwaitedReturn<T>> }) => void;
}

type Prettify<T> = {
[P in keyof T]: T[P];
} & {};

export type PromptGroup<T> = {
[P in keyof T]: (opts: {
results: Partial<PromptGroupAwaitedReturn<T>>;
results: Prettify<Partial<PromptGroupAwaitedReturn<T>>>;
}) => void | Promise<T[P] | void>;
};

Expand All @@ -673,7 +677,7 @@ export type PromptGroup<T> = {
export const group = async <T>(
prompts: PromptGroup<T>,
opts?: PromptGroupOptions<T>
): Promise<PromptGroupAwaitedReturn<T>> => {
): Promise<Prettify<PromptGroupAwaitedReturn<T>>> => {
const results = {} as any;
const promptNames = Object.keys(prompts);

Expand Down

0 comments on commit ac7d1e1

Please sign in to comment.