Loading topic
if, switch, and the ternary operator. A union type uses | to describe a value that can have one of several types.2 min readstring | number. You should also know JavaScript if, switch, and ternary expressions.2 min readstring | number and with if statements.2 min readstrictNullChecks. This chapter focuses on how TypeScript uses JavaScript truthiness to narrow a value inside an if, ternary expression, or logical expression.2 min readif statements, and switch statements. This chapter focuses on equality checks that help TypeScript choose a more specific type inside a branch.2 min readFish | Bird means a value can be either a Fish or a Bird.2 min readswitch statements, and union types such as string | number. You should also understand that TypeScript checks which operations are valid for a value before the program runs.1 min readswitch statements, and control-flow narrowing. This chapter focuses on ensuring that code handles every member of a union.2 min readunknown, and ordinary if statements. An assertion function is a function whose return type tells TypeScript that a condition is true after the function returns. The function usually throws an error when the condition is false2 min readfilter.2 min readif statements, callbacks, and basic control flow analysis. Narrowing means that TypeScript uses a check to replace a wide type with a more specific type. For example, a string | undefined value becomes string after a check 2 min read