So far I've tried:
function copyObject<K, V> (object: { [k: K]: V; }) {
var objectCopy = {};
for (var key in object)
{
if (object.hasOwnProperty(key))
{
objectCopy[key] = object[key];
}
}
return objectCopy;
}
But this gives a compiler warning: "Index signature parameter type must be 'string' or 'number'".
Maybe it's possible to constrain the key type to number or string? Or just overload it with both types as keys?