How do I make Object.entries available in TypeScript? [duplicate]

∥☆過路亽.° 提交于 2019-12-19 12:52:16

问题


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:

  • 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?
  • use a third-party library?

回答1:


You need to add

"lib": [ "es2017.object" ]

https://github.com/Microsoft/TypeScript/issues/8482#issuecomment-262847071



来源:https://stackoverflow.com/questions/42410029/how-do-i-make-object-entries-available-in-typescript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!