Dev Helpers
← Back

Await a heterogeneous promise tuple

Await a heterogeneous promise tuple using TypeScript.

Open this example in the interactive library

Source code

const load = async (id: number): Promise<{ id: number; ready: boolean }> => ({
  id,
  ready: true,
});
console.log(await Promise.all([load(1), Promise.resolve("ok")] as const));

Sample output

[ { id: 1, ready: true }, 'ok' ]