Skip to content

QuizNot attempted

Utility types

Which gives the type of the value a Promise-returning function resolves to?
async function getUser() { return { id: 1, name: 'Ann' }; }
1–4 to choose, Enter to submit
Show answer & explanation

Correct answer:

  • Awaited<ReturnType<typeof getUser>>
  • ReturnType<typeof getUser> is `Promise<{ id: number
  • name: string }>, and Awaited<>` unwraps the promise (recursively) to the resolved value.
  • Not ReturnType alone: still wrapped in Promise.
  • Not Parameters: gives the arguments tuple ([] here).
  • Not InstanceType: only works on constructor types.