It's pretty easy to do in Typescript and loses no type safety (without needing to assert or cast anything)
type T = { [k: string]: number };
const t: T = {
one: 1,
two: 2,
three: 3,
};
const makeUpperCaseKeys = (v: T): T => {
const keys = Object.keys(v);
return keys.reduce((p, c) => {
const key = c.charAt(0).toUpperCase() + c.slice(1);
return { ...p, [key]: v[c] };
}, {});
};
console.log(makeUpperCaseKeys(t));
// {
// One: 1,
// Two: 2,
// Three: 3
// }