Use power of Generics to infer types in more functions

In response to a previous [comment](https://github.com/borisyankov/DefinitelyTyped/commit/c13f86684a7f7684efc451e911b3cb488d2eadbd#commitcomment-6358040).