Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?
like image 718
user776686 Avatar asked Feb 23 '17 07:02

user776686


1 Answers

You need to add

"lib": [ "es2017.object" ]

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

like image 148
Günter Zöchbauer Avatar answered Oct 23 '22 13:10

Günter Zöchbauer