const separateResults = <T>(items: PromiseSettledResult<T>[]) => { const successfulItems = items .filter( (item): item is PromiseFulfilledResult<T> => item.status === "successful" ) .map((item) => item.value); const failedItems = items.filter( (item): item is PromiseRejectedResult => item.status === "failed" ); ...};
const separateResults = (items: PromiseSettledResult<unknown>[]) => { const successfulItems: unknown[] = []; const failedItems: unknown[] = []; for (const item of items) { if (item.status === "successful") { successfulItems.push(item.value); } else if (item.status === "failed") { failedItems.push(item.reason); } } ...};