title: Function Overloading in TypeScript vs Using a Union Type
body: <p>I am reading about function overloads.  Essentially what they are is, you are creating let's say 3 functions, with the same name, that are passing 3 different parameters and return types.  I am new to TS and I was wondering the following:  wouldn't passing a union type and returning a union type be the same?  Or is it something completely different?</p>
  <p>This is what came up in my head as an example.  Would this work or not?</p>
  <p>Overload:</p>
  <pre><code>function f1(a: string) {
  }
  function f1(a: number) {
  }
  </code></pre>
  <p>Using a union type:</p>
  <pre><code>function f1(a: string | number):string | number  {
  
  }
  </code></pre>