Lesson 3.1

Conditional types and infer

A conditional type branches on assignability, and infer pulls a type out of the branch it matched. This is how utility types are built.

14mIntermediate15.3k students

Overview

What this lesson covers

  • Branch a type on an extends check
  • Extract inner types with infer
  • Understand distribution over union members

This lesson sits in Advanced Types, part of TypeScript for Application Developers. It assumes what came before it and leads directly into the next lesson in the module.


In this lesson you will:

  • Branch a type on an extends check
  • Extract inner types with infer
  • Understand distribution over union members