Don't be mistaken, Typescript do not has proper pattern matching support,
The proposal is far from being adopted https://github.com/tc39/proposal-pattern-matching
> Related, Typescript is the only language I know of that through flow analysis does not require you to redefine the variable. E.g. you can do something like
This is called smart casting and is widely used in Kotlin