I have a function in typescript which uses Object.fromEntries to reduce a complex response object and group it using substring of the child object key.
let Newresult = res.map(object => Object.fromEntries(Object.entries(object).map(([key, value]) => [
key,
value.map(valueobject => Object.entries(valueobject).reduce((res1, [name, value]) => {
const key = name.slice(0, 5);
res1[key] = res1[key] || {};
res[key][name] = value;
return res1;
}, {}))
])));
but the problem is typescript throws below error while compiling.
error TS2339: Property 'fromEntries' does not exist on type 'ObjectConstructor'.
error TS2339: Property 'map' does not exist on type '{}'.
I tried adding ESNext,ES2017.Object into my tsconfig.json lib-array but still its throwing compilation error. but the same updates for my lib-array is allowing me to use Object.entries.
I am using angular -v-6, typescript:~3.1.1
which other method can help me achieve the same result as above. can somebody direct me in right direction?
Thanks in advance!!