如何将数组方法 polyfill 类型信息添加到数组原型中?

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

我正在为提议添加到 ECMAScript 的新组数组方法使用 core-js polyfill。

我正在使用以下方式在全球范围内导入 polyfill:

import 'core-js/actual/array/group'

我在 api 调用中使用此行的方法,我按用户名对项目进行分组。

const imagesByUser = imageResponse.items.group(({ username }) => username);

该方法运行良好并返回预期的输出,但我在这一行收到 vscode 错误:

Property 'group' does not exist on type 'DetailedImageResponse[]'.ts(2339)

我已经安装了 @types/core-js 包,但并没有解决问题。如何更新 Array 原型类型信息以包含 polyfill?

arrays typescript polyfills core-js
© www.soinside.com 2019 - 2024. All rights reserved.