Union and Intersection of types in TypeScript

Do you know, TypeScript allows union and Intersection of types? Why you need that? Let us assume you need to create a function that checks whether the passed value is boolean true and returns true, otherwise returns null. That function may look like below, function trueOrNull(foo: any): any {     if (foo === true) {         return true;     }     return undefined; } console.log(trueOrNull(88)); // null  As you see, the … Continue reading Union and Intersection of types in TypeScript