typescript check if T is value type code example
Example: typescript check type of variable
if (fooOrBar instanceof Foo){
// TypeScript now knows that `fooOrBar` is `Foo`
}
if (fooOrBar instanceof Foo){
// TypeScript now knows that `fooOrBar` is `Foo`
}