I’m trying to use Map.groupBy
, but typescript is not happy with this error :
Property ‘groupBy’ does not exist on type ‘MapConstructor’
const inventory = [
{ name: 'asparagus', type: 'vegetables', quantity: 9 },
{ name: 'bananas', type: 'fruit', quantity: 5 },
{ name: 'cherries', type: 'fruit', quantity: 12 },
]
const result = Map.groupBy(inventory, ({ type }) => type)
}
I have typescript 5.4.5 and Node 22.0.0
tsconfig.json targets esnext
"compilerOptions": {
"target": "ESNext",
"skipLibCheck": true
}