Course lesson
Validate Brand Typed Expressions with Custom Type Guards
Type Guards are expressions that guarantee the type of a value. In this lesson, we'll create functions that check if the values we pass them are valid types in our system.
- Duration
- 4 min
- Access
- Included
- Transcript
- Retained from source evidence
Type Guards are expressions that guarantee the type of a value. In this lesson, we'll create functions that check if the values we pass them are valid types in our system.
A great example here is with emails. Emails are strings with a very specific set of requirements. The type guard checks those requirements and if they pass then TypeScript will refer to that value as an Email instead of a string