title: Angular 6 - How to define return value type with more than 1 type
body: <p>I have a return function in Angular 6, and I want to define the return value type. But the problem is, my function can be used in several cases, and the return value is based on the case.
  Here is my code below:</p>
  
  <pre><code>updateProcess(type, list, event: {}) {
      let newList = [];
      switch (event["action"]) {
          case ListManipulation.Add:
              newList = list;
              newList.push(event["data"]);
              break;
          case ListManipulation.Delete:
              newList = list.filter(
                  setting =&gt; !event["data"].includes(setting[this.itemProperties[type]["idName"]])
              );
              break;
          default:
              newList = list;
              break;
      }
      return [...newList];
  }
  </code></pre>
  
  <p>and suppose you have one type for the return value, you can do it like this:</p>
  
  <pre><code>updateProcess(type, list, event: {}): string {
  </code></pre>
  
  <p>But what I want to do is:</p>
  
  <pre><code>updateProcess(type, list, event: {}): string | [] | {} {
  </code></pre>
  
  <p>Can anyone help?</p>
  
  <p>PS. Also I need that for type of <strong><em>list</em></strong> as parameter</p>