Type Narrowing#

Narrowing is how TypeScript refines a broad type to a more specific one inside conditional blocks. TypeScript understands typeof, instanceof, in, equality checks, and custom type guards to narrow types automatically.

Built-in Narrowing

Using typeof, instanceof, and in to narrow types

TypeScript automatically narrows types in conditional branches