1//You need to make the object first, then use [] to set it.
2
3var key = "happyCount";
4var obj = {};
5obj[key] = someValueArray;
6myArray.push(obj);
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