How TypeScript infers type variables

6 points by norswap