Conditional Types Introduction

This lesson introduces conditional types.

Introduction

Conditional types are type constructors that create a type based on some condition. In other words, they are a special kind of generic type where you can inspect the type argument and “return” a different type based on whether or not it satisfies a given type condition.

There is only one kind of condition allowed in conditional types and you can check whether the provided type argument is assignable to some type. You can think of type assignability the same way you’d think of value equality in a regular condition. In fact, even the syntax for conditional types is similar to regular ternary expressions.

Get hands-on with 1200+ tech skills courses.