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.

Duration
14m
Level
Intermediate
Students
15k students

Overview

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

In this lesson you will:

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

Resources

TypeScript handbook

The official reference for the tools used in this lesson.