Skip to content

Glossary: TypeScript Beyond the Basics

User-defined type guard

Also written: type guard, type guards, user-defined type guards

A function that returns a type predicate, so TypeScript narrows a value after the check. `isCarrier` narrows a string to `Carrier`, but TypeScript trusts a guard without checking it.

Where the book teaches it

Related terms

Type predicateNarrowingAssertion function