title: How to resolve typescript union types of interfaces with type guards
body: <p>Angular's <code>$http.defaults.transformRequest</code> is defined as:</p>
  
  <pre><code>transformRequest?: IHttpRequestTransformer |IHttpRequestTransformer[];
  </code></pre>
  
  <p>Now I want to append an own transformer, so I need to check if this is already an array. I thought a simple typeguard with</p>
  
  <pre><code>function x(): angular.IHttpRequestTransformer[] { 
      if($http.defaults.transformRequest instanceof Array){
         return $http.defaults.transformRequest;
      }
  }
  </code></pre>
  
  <p>would work, however, inside the if clause idea still thinks it is a union type. I also tried <code>instanceof</code> and <code>$http.defaults.transformRequest.length === undefined</code>, nothing worked.</p>
  
  <p>Can anyone hint me in the right direction how I can tell IDEA that I've already ensured that <code>$http.defaults.transformRequest</code> is an array?</p>
  
  <p>Thank!</p>