Understanding the type system of TypeScript