title: Typescript: How to map object to type?
body: <p>Assume that I have an object containing some data. I want to build a generic mapper (only a function respectively - I don't want to instantiate a new class all the time) for all types to use like this: <code>this.responseMapper.map&lt;CommentDTO&gt;(data);</code></p>
  
  <p>It should simply take all properties from the given type and map the data to it.
  What I tried so far:</p>
  
  <pre><code>public map&lt;T&gt;(values: any): T {
      const instance = new T();
  
      return Object.keys(instance).reduce((acc, key) =&gt; {
          acc[key] = values[key];
          return acc;
      }, {}) as T;
  }
  </code></pre>
  
  <p><code>new T();</code> will throw an error: <code>'T' only refers to a type, but is being used as a value here.</code></p>
  
  <p>What's the correct way to do this?</p>