title: Accept Array of Interfaces OR single interface in TypeScript
body: <p>Really new in TypeScript. I have an array of presets that the user can add or modify existing ones. Since it has a couple of keys only, I made an interface. </p>
  
  <pre><code>interface IStylePreset {
      type : string;
      backgroundColor : string;
      color? : string
  }
  </code></pre>
  
  <p>And the implementation is here:</p>
  
  <pre><code>static stylePresets : Array&lt;IStylePreset&gt; = [
      { type: "default", backgroundColor: "#37474f" , color: "#ECEFF1"},
      { type: "success", backgroundColor: "#37474f", color: "#ECEFF1" },
      { type: "error", backgroundColor: "#d32f2f", color: "#EEE"}
  ];
  </code></pre>
  
  <p>Now I have a config function that takes a custom preset to either change existing presets or add new ones.</p>
  
  <pre><code>static config = {
      types(newPresets) : void {
          newPresets = [].concat(newPresets);
          for(var i = 0, len = newPresets.length, current; i&lt; len; i++){
              var pos = Message.Util.find(Message.stylePresets, newPresets[i].type)
              current = newPresets[i];
              if(pos !== -1) for(var key in current) Message.stylePresets[pos][key] = current[key];
              else Message.stylePresets[Message.stylePresets.length] = current;
              }
          }
      };
  </code></pre>
  
  <p>The problem is, I can't figure out what to specify in the type of <code>newPresets</code> since it's accepting both an array of objects and as well as a single object (which makes into a single element array <code>newPresets = [].concat(newPresets);</code>).</p>
  
  <p>I'm trying to learn TypeScript and I don't know if what I'm doing is right. Can someone please help me out here? Further reading material or docs would be gold. </p>