How TypeScript understands the types of our variables in every single line? How can narrow down types to more specific ones? This episode is an introduction to TypeScript Control Flow Analysis. Discover all the available Type Guards. Get familiar with the weird parts of JavaScript, like Coercion. Understand how you can create your own Type Guards using type predicates. We will also learn how to ensure that a switch statement exhausts all possible values.
Contents
00:00 Intro
01:21 Coding Challenge
02:27 Solution
03:41 Control Flow Analysis
05:48 Type Guards
07:41 typeof Operator
09:45 instanceof Operator
11:33 if Operator
12:18 Falsy values
12:58 Truthy values
14:12 Ternary operator
14:54 Switch Statements
15:18 Exhaustiveness Checking
17:58 Logical Operators
20:25 Comparison Operators
23:02 Coercion
25:35 in Operator
26:32 Type Predicates
28:46 Outro
Check out my ✨TypeScript course:
https://tltr-typescript.com
Links I mention in the video
Truth/Falsy values:
https://developer.mozilla.org/en-US/d...
https://developer.mozilla.org/en-US/d...
Learn about Type Coercion:
https://developer.mozilla.org/en-US/d...
My previous video about classes:
• Master Classes In TypeScript
My blog post with all the coding examples:
https://nicotsou.com/tltr-typescript-...
This video belongs to my series Too Long To Read TypeScript. Every episode covers in detail a core concept of the language.
You can support this channel by clicking SUBSCRIBE :)