Typescript union to intersection. How TypeScript infers types based on runtime behavior.