title: Typescript iterate over a Record type and return updated Record
body: <p>I am new to <strong>Typescript</strong> and I need to iterate over a <code>Record</code> type make some updates to the values and return the <code>Record</code>.</p>
  <p>This is how the types are defined:</p>
  <pre><code>type Parent = Readonly&lt;Record&lt;string, Children&gt;&gt;;
  type Children = ReadonlyArray&lt;string&gt;;
  </code></pre>
  <p>Here is some sample data I would like to iterate over:</p>
  <pre><code>const data = {
      parent1: [&quot;child1&quot;, &quot;child2&quot;],
      parent2: [&quot;child1&quot;,&quot;child2&quot;]
  };
  </code></pre>
  <p>Method to update values in record:</p>
  <pre><code>const updateChildren = (child: Children) : Children =&gt; {
      return child.map( value =&gt; value + 'updated');
  }
  </code></pre>
  <p>I am struggling to write the syntax for it, tried to look for examples but couldn't find anything helpful.</p>
  <p>I am able to iterate over the record using <code>Object.entries</code></p>
  <pre><code>Object.entries(data).forEach(([key, value]) =&gt; console.log(key, value));
  </code></pre>
  <p>I also tried to use <code>Object.keys</code></p>
  <pre><code>Object.keys(data)
              .map(key =&gt; updateChildren(data[key]))
  </code></pre>
  <p>I guess I am close but not sure how to return the map as here its returning <code>Array [Array]</code></p>
  <p>Is there some nice way to iterate do the update and it would return the updated data in same type used.</p>
  <p>Thanks for reading.</p>
  <p>Here is the javascript snippet of what I am trying to do and get the <code>updatedMap</code> in example below.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const data = {
      parent1: ["child1", "child2"],
      parent2: ["child1","child2"]
  };
  
  function updateChildren(children) {
    return children.map(child =&gt; child+'updated');
  }
  
  const updatedMap = new Map();
  
  for (const [key, value] of Object.entries(data)) {
    updatedMap.set(key, updateChildren(value));
  }
  
  updatedMap.forEach((value, key) =&gt; console.log(key + ":" + value));
  
  
  console.log(Object.keys(data).map(key =&gt; updateChildren(data[key])));</code></pre>
  </div>
  </div>
  </p>