How TypeScript infers type variables

This is the second article about what I learned about the TypeScript type system while writing a small library. This one is about how TypeScript assigns a type to type variables defined in functions via inference. You can also read the first article about how TypeScript distributes unions . Type variable inference is a complex process. It often does what you expect or want, although when you're…