title: RangeError: Invalid array length at array spread
body: <p>I have a rather standard item hydration function that throws "<strong>RangeError: Invalid array length</strong>". Unfortunately this happens very rarely and in the production so it's hard to catch the input params.</p>
  
  <p>This is the function:</p>
  
  <pre class="lang-js prettyprint-override"><code>function setProgress(items: SomeType[], id: string, someProperty: string) {
    const index = items.findIndex(item =&gt; item.id === id);
    const newItem: SomeType = {...items[index], someProperty };
  
    return [...items.slice(0, index), newItem, ...items.slice(index + 1); 
  }
  </code></pre>
  
  <p>And this is what is transpiles to (non-uglified):
  </p>
  
  <pre><code>function setProgress(items, id, someProperty) {
    var index = items.findIndex(function(e) {
        return items.id === id
      }), 
      newItem = Object.assign({}, items[index], {
        someProperty: someProperty
      });
    return items.slice(0, index).concat([newItem], items.slice(index + 1));
  }
  </code></pre>
  
  <p>I've tried playing with different values but I cannot reproduce this error.</p>
  
  <p>Any idea what and how could cause this?</p>