How do I type a function, so that the input object is the same as the output object, but with different values?
//a has type { a: number;b: number }
let a = { 'a': 1, 'b': 1 };
interface IDictNumber {
[key: string]: number;
}
interface IDictString {
[key: string]: string;
}
function convert(f: IDictNumber) {
return Object.keys(f)
.reduce((p, v) => {
p[v] = `${f[v]}`;
return p;
},
{} as IDictString);
}
//b has type IDictString, but I wanted it to have { a: string;b: string }
let b= convert(a);