title: Generics in typescript - not assignable to type / parameter of type
body: <p>I am having the following two service calls, which both are using the method concertDates().</p>
  <pre><code>private callMyFirstService(params: MyParams): Observable&lt;MyDto&gt; {
      return this.http.post&lt;MyDto&gt;(params).pipe(map(response =&gt; this.convertDates&lt;MyDto&gt;(response)));
  }
  
  private callMySecondService(params: MyOtherParams): Observable&lt;MyAnotherDto&gt; {
      return this.http.post&lt;MyAnotherDto&gt;(params).pipe(map(response =&gt; this.convertDates&lt;MyAnotherDto&gt;(response)));
  }
  </code></pre>
  <p>Since these methods are operating with another type of dtos, I try to implement some generic funtion which can be called in both cases.
  I have something like that:</p>
  <pre><code>private convertDates&lt;type&gt;(input: type): type {
      for (const key in input) {
          if (!input.hasOwnProperty(key)) {
              continue;
          }
  
          if (typeof input[key] === 'object') {
              this.convertDates(input[key]);
          } else if (typeof input[key] === 'string' &amp;&amp; this.MY_REGEXP.test(input[key])) {
              input[key] = new Date(input[key]);
          }
      }
      return input;
  }
  </code></pre>
  <p>This does not seem to work, becase I always get:</p>
  <pre><code>Type 'Date' is not assignable to type 'type[Extract&lt;keyof type, string&gt;]'
  </code></pre>
  <p>and...</p>
  <pre><code>Argument of type 'type[Extract&lt;keyof type, string&gt;]' is not assignable to parameter of type 'string'.
    Type 'type[string]' is not assignable to type 'string'.
  </code></pre>
  <p>Any ideas?
  Thanks a lot in advance!</p>