Type Guard
Noun · Development
Definitions
A runtime check that narrows the type of a variable within a conditional block. In TypeScript, type guards use typeof, instanceof, or custom predicates to tell the compiler a value is a more specific type.
In plain English: A check in your code that proves to both you and the compiler that a value is a specific type, unlocking access to that type's properties.
Example: "Add a type guard so TypeScript knows the response is a User, not just unknown."