title: TypeScript - How to use array map to an ES 6 Map?
body: <p>Lets say I have an array of key value objects:</p>
  
  <pre><code>const data = [
      {key: "object1", value: "data1"},
      {key: "object2", value: "data2"},
      {key: "object3", value: "data3"},
  ]
  
  const mappedData = data.map(x =&gt; [x.key, x.value]);
  
  const ES6Map = new Map&lt;string, string&gt;(mappedData.values())
  </code></pre>
  
  <p>How do I convert it to ES 6 map? It works in JavaScript but TypeScript will complain. Here I got the error of <code>Argument of type 'IterableIterator&lt;string[]&gt;' is not assignable to parameter of type 'ReadonlyArray&lt;[string, string]&gt;'.
    Property 'length' is missing in type 'IterableIterator&lt;string[]&gt;'.</code></p>