📜  typescript 对象键类型 - TypeScript 代码示例

📅  最后修改于: 2022-03-11 14:48:13.884000             🧑  作者: Mango

代码示例3
// For every properties K of type T, transform it to U
function mapObject(obj: Record, f: (x: T) => U): Record

const names = { foo: "hello", bar: "world", baz: "bye" };
const lengths = mapObject(names, s => s.length);  // { foo: number, bar: number, baz: number }