instanceof is a type Guard, which checks if a value is an instance of a class or a constructor function. It also acts as a Type Guard, helping us the infer the type correctly in the scope
Union Types in Typescript allows a variable to have the ability to store a value of several types. We define union types by using a pipe- (|) to separate each of the possible types. Hence, number | string | boolean is the type of a variable, which can have the value that can be a number, a string, or a boolean.
TypeScript Literal Types restrict the value of a variable to finite valid values. The latest version of Typescript supports the following Literal Types. String Literal Types,Numeric Literal Types,Boolean Literal Types & Enum Literal Types. This is very useful feature which restrict the possible values, that you can store in a variable
The Typescript Never type represents the type that never happens or the values that never occur. The following are such places where we use the never type. The return type of function that never returns (infinite loop or always throws an error). Variables when narrowed by a Type guard that can never be true