如何在TypeScript中使Object.entries可用? [英] How do I make Object.entries available in TypeScript?
本文介绍了如何在TypeScript中使Object.entries可用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的angular-cli构建的应用程序(当前正在使用TypeScript 2.0.3)中,我希望能够使用此基于分解的迭代器:
In my angular-cli-built app (which is currently using TypeScript 2.0.3) I want to be able to use this decomposition-based iterator:
for (let [key, value] of Object.entries(obj)) {
}
要使其被识别,我该怎么做:
What do I have to do in order to have it recognized:
- 升级TypeScript吗?
- 使用polyfill?
- 如果是这样:如何将其导入-在单个.ts文件或配置文件中以使其在全球范围内可用?
- upgrade TypeScript?
- use a polyfill?
- if so: how do I import it - in individual .ts files or in a config file to make it globally available?
推荐答案
您需要添加
"lib": [ "es2017.object" ]
https://github.com/Microsoft/TypeScript/issues/8482# issuecomment-262847071
这篇关于如何在TypeScript中使Object.entries可用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文