Cleaner Type Predicates with Derived Types

from blog Aleksandr Hovhannisyan, | ↗ original
In TypeScript, type predicates allow you to narrow down an abstract type to a more concrete type with a simple assertion. Together with derived types, they can greatly reduce repetition in your code.