Playing around with generics in typescript