title: could be instantiated with an arbitrary type which could be unrelated to 'string'
body: <p>I have the following function</p>
  
  <pre><code>function pickAndTrim &lt;T&gt; (keys : Array&lt;string&gt;, object : T ) : T {
      function trim &lt;A&gt; (input : A) : A {
              if (typeof input === "string") {
                  return input.trim();
              }
              return input;
      }
      let updates = R.pick(keys, object);
      updates = R.map(trim, updates);
      return updates;
  }
  </code></pre>
  
  <p><strong>Note:</strong> R is Ramda</p>
  
  <p>What it's doing is that it takes an Object, picks certain keys (and values) from it, then trims any values from that resulting Object if it's a string.</p>
  
  <p>The current error I'm getting is:</p>
  
  <pre><code>Type 'string' is not assignable to type 'A'.
    'A' could be instantiated with an arbitrary type which could be unrelated to 'string'.
  </code></pre>
  
  <p>How do I make typescript accept that it definitely it is a string (since I checked it with <code>typeof</code>)</p>