title: How to discriminate type and array of type in typescript?
body: <p>In typescript, how can I discriminate between a user defined type and an array of such type?</p>
  <pre><code>type SomeType = { foo: string; };
  
  function doSomething(x: SomeType | SomeType[]) {
      // Is x an array?
  }
  </code></pre>
  <p>When the argument is a primitive type or an array, it is straightforward with <code>typeof</code>, but this does not work with user defined types.</p>