1// For every properties K of type T, transform it to U
2function mapObject<K extends string, T, U>(obj: Record<K, T>, f: (x: T) => U): Record<K, U>
3
4const names = { foo: "hello", bar: "world", baz: "bye" };
5const lengths = mapObject(names, s => s.length); // { foo: number, bar: number, baz: number }
6