AI Features

Union Types and Type Guards

Let's look at union types and type guards in this lesson.

We'll cover the following...

Type guards

TypeScript calls the functionality that lets us use a specific type a type guard. A type guard is a block of code where you narrow the definition of a union type in such a way that TypeScript can infer the narrower type and use that information to type check the ...