Type the function `PromiseAll` that accepts an array of PromiseLike objects, the returning value should be `Promise<T>` where `T` is the resolved result array. Learn array type operations, Promise type handling in this medium-level challenge on TypeScriptPro.
Type the function PromiseAll
that accepts an array of PromiseLike objects, the returning value should be Promise<T>
where T
is the resolved result array. ⏳
In this medium-level challenge, you'll type the function promiseall
that accepts an array of promiselike objects, the returning value should be promise<t>
where t
is the resolved result array.. Learn array type operations, Promise type handling in this medium-level challenge on TypeScriptPro.
You'll learn about array type operations, Promise type handling, essential skills for advanced TypeScript development and type-level programming.
For this challenge, you will need to change the following code to make the tests pass (no type check errors).
Type the function PromiseAll
that accepts an array of PromiseLike objects, the returning value should be Promise<T>
where T
is the resolved result array.
const promise1 = Promise.resolve(3);
const promise2 = 42;
const promise3 = new Promise<string>((resolve, reject) => {
setTimeout(resolve, 100, 'foo');
});
// expected to be `Promise<[number, 42, string]>`
const p = PromiseAll([promise1, promise2, promise3] as const)
This challenge requires understanding of array type operations and Promise type handling.
The solution involves carefully constructing types that satisfy all test cases while handling edge cases properly.
This challenge helps you understand array type operations and how to apply these concepts in real-world scenarios.
Be the first to access the course, unlock exclusive launch bonuses, and get special early-bird pricing before anyone else.
Only 27 Spots left
Get 1 month early access
Pre-Launch discount
This challenge is originally from here.