如何让新的Map.groupBy在TypeScript/Angular项目中工作?

问题描述 投票:0回答:1

我想在 NX/Angular/TypeScript 项目中使用新的

Map.groupBy
函数,但这不起作用。

我遇到 IDE 错误,提示该函数无法识别。 我已经修复了更新

tsconfig.base.json
文件以使用 ESNext:

"lib": ["ESNext", "dom"],

现在,由于类似的错误,我的单元测试无法在运行时运行:

Map.groupBy is not a function
TypeError: Map.groupBy is not a function

要使其发挥作用需要什么要求?

angular typescript ecmascript-next
1个回答
0
投票

此功能仅适用于节点版本 >= 21.0.0,而我使用的是较低版本

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/groupBy#browser_compatibility

© www.soinside.com 2019 - 2024. All rights reserved.