title: Typescript Union Types
body: <p>I am moving from Javascript to Typescript and am trying to create a class method which can take a JQuery object or an array of them. I am trying to use a union type but cannot seem to get the matching to work with the JQuery parameter:</p>
  
  <pre><code>setToGrey($items: JQuery[]|JQuery) {
      if ($items instanceof Array) {
          for (var i = 0; i &lt; $items.length; i++) {
              var $item = $items[i];
              this.resetIcon($item);
              $item.addClass(CSSClasses.TEXT_MUTED).find("span." + CSSClasses.GLYPHICON).addClass(CSSClasses.ICON_QUESTION_CICLE);
          }
      } else if ($items instanceof JQuery) {
          this.resetIcon($items);
          $items.addClass(CSSClasses.TEXT_MUTED).find("span." + CSSClasses.GLYPHICON).addClass(CSSClasses.ICON_QUESTION_CICLE);
      }
  }
  </code></pre>
  
  <p>I cannot get the line:</p>
  
  <pre><code>} else if ($items instanceof JQuery) {
  </code></pre>
  
  <p>to work, the error comes up as Cannot find name 'JQuery'.</p>
  
  <p>I'm not sure where my misunderstanding is. What am I doing wrong?</p>