Skip to content
Guest
Learn TypeScript · Course Syllabus Show lessons
Production TypeScript · 8 min read · Intermediate

Typing Async Functions & Promises

Annotate async functions with Promise<T>, unwrap return types with Awaited<T>, and type API responses cleanly.

What you'll learn

  • Return Promise<T> cleanly from async functions
  • Extract the resolved type of a Promise using Awaited<T>
  • Type Promise.all() tuples automatically

Every async function automatically wraps its return value in a Promise<T>. When calling Promise.all([fetchUser(), fetchScore()]), TypeScript automatically preserves a strongly typed tuple [User, number].

Fill-in-the-Blank Exercise

Typed Async Return

Annotate loadCount as returning a Promise that resolves to a number.

async function loadCount(): <> {
return 18;
}

Live Code Lab

TypeScriptasync_ts.ts
Expected OutputClick “Run Live” to compile with TypeScript 5.6
TypeScript+React = 24 lessons

Check Your Understanding

Score: 0 / 1

1. What is the return type of `async function getScore() { return 95; }` in TypeScript?

Study Workspace

Finished this lesson?

Your progress is saved locally in your browser, no account needed.

Search courses, lessons, and references

Type to search across all courses, lessons, and quick references.

Press Esc to close Powered by Pagefind