title: Different return by generics statements, javascript
body: <p>Is there way to return different values by <strong>generic statements?</strong></p>
  
  <p>Example:  </p>
  
  <pre><code>//How should i write function, which will be used as follows?:
  type FooType&lt;T&gt; = T | T[]
  let baz: FooType&lt;Object[]&gt; = Foo&lt;Object[]&gt;('bar') // returns: [{bar: 'bar'}]
  let bazbar: FooType&lt;Object&gt; = Foo&lt;Object&gt;('bar') // returns: { bar: 'bar' }
  </code></pre>