Type Guard
/taɪp ɡɑːd/
Definition
A TypeScript function or expression that narrows a type within a conditional block.
Example in context
"if (typeof value === 'string') — inside that block TypeScript knows value is a string, not a string | number."
Related terms
Practice this term
Master Type Guard in context by working through exercises in the JavaScript & TypeScript module. You'll see the term used in real engineering scenarios with multiple-choice, fill-in-the-blank, and matching drills.