You cannot do it for TypeArguments in generics (as you have already realized). But you can do runtime checking if you use TypeScript classes:
class Group{}
function getKey(item:any): string {
if (item instanceof Group)
return "Groups";
else
return 'invalid';
}
console.log(getKey(new Group()));
There is no typescript magic in the above code. We are simply utilizing the javascript instanceof operator : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof