TypeScript · Senior · Question 43 of 75
How do you type a Promise.all-like function over a tuple of promises?
- ✓Correct answer: A generic tuple
[...T]and a mapped type withAwaited<T[K]> - 2An array
Promise<any>[]and a resultPromise<any[]> - 3One generic
Tfor all promises andPromise<T>
Explanation
[...T] hints to infer a tuple rather than an array, and the homomorphic mapped type unwraps each element: all([fetchUser(), fetchPosts()]) → Promise<[User, Post[]]>. Versions with any or a single T lose positional types.