[READ-ONLY] Mirror of https://github.com/bombshell-dev/clack. Effortlessly build beautiful command-line apps bomb.sh/docs/clack/basics/getting-started/
cli command-line command-line-app node prompt prompts
5

Configure Feed

Select the types of activity you want to include in your feed.

fix: weaken internal group types to strengthen return/onCancel types

This changes a few things.

First of all, trying to infer `T` while defining `T` currently doesn't
work unless there's a member without the `results` arg. This is a known
limitation that may or may not be fixed in typescript one day.

Until that happens, if ever, this dumbs down the type of `results` to be
a `Record<PropertyKey, unknown>`. This means _within a function_ you
lose strong typing, but the return type will now always be correct.

Secondly, `T` is actually the resulting already-awaited shape. This
means we do not need `Awaited<T[K]>` since `T[K]` is already the awaited
type.

For example:

```ts
type ActualType = {
foo: number;
bar: number;
};
group<ActualType>({
foo: () => Promise.resolve(303),
bar: () => Promise.resolve(808)
});
```

You can see the `ActualType` never needed `Awaited<T>` on each type
since it is already the final result.

James Garbutt (Mar 7, 2025, 3:26 PM +0100) 3e7a7de3 5529c890

+3 -7
+3 -7
packages/prompts/src/index.ts
··· 844 844 }; 845 845 }; 846 846 847 - export type PromptGroupAwaitedReturn<T> = { 848 - [P in keyof T]: Exclude<Awaited<T[P]>, symbol>; 849 - }; 850 - 851 847 export interface PromptGroupOptions<T> { 852 848 /** 853 849 * Control how the group can be canceled 854 850 * if one of the prompts is canceled. 855 851 */ 856 - onCancel?: (opts: { results: Prettify<Partial<PromptGroupAwaitedReturn<T>>> }) => void; 852 + onCancel?: (opts: { results: Prettify<Partial<T>> }) => void; 857 853 } 858 854 859 855 type Prettify<T> = { ··· 862 858 863 859 export type PromptGroup<T> = { 864 860 [P in keyof T]: (opts: { 865 - results: Prettify<Partial<PromptGroupAwaitedReturn<Omit<T, P>>>>; 861 + results: Record<PropertyKey, unknown>; 866 862 }) => undefined | Promise<T[P] | undefined>; 867 863 }; 868 864 ··· 873 869 export const group = async <T>( 874 870 prompts: PromptGroup<T>, 875 871 opts?: PromptGroupOptions<T> 876 - ): Promise<Prettify<PromptGroupAwaitedReturn<T>>> => { 872 + ): Promise<Prettify<T>> => { 877 873 const results = {} as any; 878 874 const promptNames = Object.keys(prompts); 879 875