title: Typescript: Map properties from one object to another
body: <p>I have the following two types and object.</p>
  <pre class="lang-js prettyprint-override"><code>type TypeA = {
    a: number;
    b: number;
    c: number;
  };
  type TypeB = {
    d: number;
    e: number;
    c: number;
  };
  oldObject: { [key: string]: TypeA };
  
  </code></pre>
  <p>I want to map the properties from an object of type <code>TypeA</code> to an object of type <code>TypeB</code>. So far I've come up with the following.</p>
  <pre class="lang-js prettyprint-override"><code>const newObject: { [key: string]: TypeB } = {};
  
  Object.entries(oldObject).forEach(([key, value]) =&gt; {
    newObject[key] = {
      d: value.a,
      e: value.b,
      c: value.c,
    } as TypeB;
  });
  </code></pre>
  <p>Is there any way of doing this in typescript with something like a map or reduce function? I would much prefer to not have to assign <code>{}</code> to <code>newObject</code> at first.</p>