Iterating over Typescript Map

前端 未结 12 1795
无人共我
无人共我 2020-12-07 16:26

I\'m trying to iterate over a typescript map but I keep getting errors and I could not find any solution yet for such a trivial problem.

My code is:

         


        
12条回答
  •  死守一世寂寞
    2020-12-07 16:44

    On Typescript 3.5 and Angular 8 LTS, it was required to cast the type as follows:

    for (let [k, v] of Object.entries(someMap)) {
        console.log(k, v)
    }
    

提交回复
热议问题