class Promise {
// This looks a bit complex 🧐
all<Promises extends unknown[]>(promises: Promises): Promise<{
[Index in keyof Promises]: Awaited<Promises[Index]>;
}>;
}
{[Index in keyof Promises]: Awaited<Promises[Index]>;}
는 객체처럼 보이지만 배열도 할당 가능하다. 배열이 {}
에 할당 가능하다는걸 생각하면 자연스러움. 숫자key가 있는 객체는 타입 레벨에서 배열로 취급 가능하다.