Skip to content

Asserts & Type Guards

Webber Wang edited this page Sep 21, 2020 · 6 revisions

Type Guards

Type guards are used for conditional statements. If we have a Factory function we will use type guards

if (isNodeReact) {}
else if (isNodeTree) {}

Assertions

Asserts on the other hand is used to narrow down the type for further statements.

isID casts the type from string string | undefined

Clone this wiki locally