<h2 dir="auto">Bug Report</h2>
<p dir="auto"><strong>Current Behavior</strong><br>
A clear and concise description of the behavior.</p>
<p dir="auto"><strong>Input Code</strong><br>
<a href="https://babeljs.io/en/repl#?babili=false&amp;browsers=last%202%20Chrome%20versions%2C%0Alast%202%20Firefox%20versions%2C%0Alast%202%20Edge%20versions%2C%0Alast%202%20Safari%20versions&amp;build=&amp;builtIns=false&amp;spec=false&amp;loose=false&amp;code_lz=PTAEBcAsEsGdQOYFNz3AJwIYDtYAdoAbJAE1D3QHs8l1CBPAKGnCQFtYA6NzPACj4BvAEaZ0AGlCdp6JLHABfAJSgAvAD5Q2AK6FCSgNyNi4UCLGTpnWfIVrQADyOMQEGPBKU52AOThmrBzcvAIA2gBmlJSS5hJSMnKKALoqGlq6-kYmoBFRAEwxougF8daJeQpJ9k6MQA&amp;debug=false&amp;forceAllTransforms=false&amp;shippedProposals=false&amp;circleciRepo=&amp;evaluate=false&amp;fileSize=false&amp;timeTravel=false&amp;sourceType=module&amp;lineWrap=false&amp;presets=env&amp;prettier=false&amp;targets=&amp;version=7.5.5&amp;externalPlugins=" rel="nofollow">REPL</a></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// this gets transpiled properly
items.map(({bar, ...rest}) =&gt; null);
let {bar, ...rest} = x;

// this doesn't
items.map(([foo, {bar, ...rest}]) =&gt; null);
let [foo2, {bar2, ...rest2}] = x;"><pre class="notranslate"><span class="pl-c">// this gets transpiled properly</span>
<span class="pl-s1">items</span><span class="pl-kos">.</span><span class="pl-en">map</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-kos">{</span>bar<span class="pl-kos">,</span> ...<span class="pl-s1">rest</span><span class="pl-kos">}</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-c1">null</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-k">let</span> <span class="pl-kos">{</span>bar<span class="pl-kos">,</span> ...<span class="pl-s1">rest</span><span class="pl-kos">}</span> <span class="pl-c1">=</span> <span class="pl-s1">x</span><span class="pl-kos">;</span>

<span class="pl-c">// this doesn't</span>
<span class="pl-s1">items</span><span class="pl-kos">.</span><span class="pl-en">map</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-kos">[</span><span class="pl-s1">foo</span><span class="pl-kos">,</span> <span class="pl-kos">{</span>bar<span class="pl-kos">,</span> ...<span class="pl-s1">rest</span><span class="pl-kos">}</span><span class="pl-kos">]</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-c1">null</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-k">let</span> <span class="pl-kos">[</span><span class="pl-s1">foo2</span><span class="pl-kos">,</span> <span class="pl-kos">{</span>bar2<span class="pl-kos">,</span> ...<span class="pl-s1">rest2</span><span class="pl-kos">}</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-s1">x</span><span class="pl-kos">;</span></pre></div>
<p dir="auto"><strong>Expected behavior/code</strong><br>
<code class="notranslate">[foo, {bar, ...rest}]</code> being transpiled since Edge doesn't support it.</p>
<p dir="auto">This looks superficially similar to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="284314511" data-permission-text="Title is private" data-url="https://github.com/babel/babel/issues/7099" data-hovercard-type="issue" data-hovercard-url="/babel/babel/issues/7099/hovercard" href="https://github.com/babel/babel/issues/7099">#7099</a> but that one is supposedly <a href="https://github.com/babel/babel/issues/7099#issuecomment-357065187" data-hovercard-type="issue" data-hovercard-url="/babel/babel/issues/7099/hovercard">resolved in Babel 7</a> but my bug isn’t. Therefore I’m filing a new one.</p>
<p dir="auto">Here is a complete repro:</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="npm i --save @babel/core@7.0.0-beta.37 @babel/plugin-proposal-object-rest-spread@7.0.0-beta.37"><pre class="notranslate">npm i --save @babel/core@7.0.0-beta.37 @babel/plugin-proposal-object-rest-spread@7.0.0-beta.37</pre></div>
<p dir="auto">Then run in Node shell:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="console.log(
  require('@babel/core').transform(
`
const { ...rest1 } = {};
const [{ ...rest2 }] = [{}];
`,
    {
      plugins: ['@babel/plugin-proposal-object-rest-spread']
    }
  ).code
)"><pre class="notranslate"><span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span>
  <span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">'@babel/core'</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">transform</span><span class="pl-kos">(</span>
<span class="pl-s">`</span>
<span class="pl-s">const { ...rest1 } = {};</span>
<span class="pl-s">const [{ ...rest2 }] = [{}];</span>
<span class="pl-s">`</span><span class="pl-kos">,</span>
    <span class="pl-kos">{</span>
      <span class="pl-c1">plugins</span>: <span class="pl-kos">[</span><span class="pl-s">'@babel/plugin-proposal-object-rest-spread'</span><span class="pl-kos">]</span>
    <span class="pl-kos">}</span>
  <span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-c1">code</span>
<span class="pl-kos">)</span></pre></div>
<p dir="auto">Notice how I have two different rest destructurings, but the second one is <em>also</em> inside an array destructuring.</p>
<p dir="auto">Output:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i &lt; sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) &gt;= 0) continue; target[key] = source[key]; } if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i &lt; sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) &gt;= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

const rest1 = _objectWithoutProperties({}, []);

const [{ ...rest2
}] = [{}];"><pre class="notranslate"><span class="pl-k">function</span> <span class="pl-en">_objectWithoutProperties</span><span class="pl-kos">(</span><span class="pl-s1">source</span><span class="pl-kos">,</span> <span class="pl-s1">excluded</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">source</span> <span class="pl-c1">==</span> <span class="pl-c1">null</span><span class="pl-kos">)</span> <span class="pl-k">return</span> <span class="pl-kos">{</span><span class="pl-kos">}</span><span class="pl-kos">;</span> <span class="pl-k">var</span> <span class="pl-s1">target</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span><span class="pl-kos">}</span><span class="pl-kos">;</span> <span class="pl-k">var</span> <span class="pl-s1">sourceKeys</span> <span class="pl-c1">=</span> <span class="pl-v">Object</span><span class="pl-kos">.</span><span class="pl-en">keys</span><span class="pl-kos">(</span><span class="pl-s1">source</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-k">var</span> <span class="pl-s1">key</span><span class="pl-kos">,</span> <span class="pl-s1">i</span><span class="pl-kos">;</span> <span class="pl-k">for</span> <span class="pl-kos">(</span><span class="pl-s1">i</span> <span class="pl-c1">=</span> <span class="pl-c1">0</span><span class="pl-kos">;</span> <span class="pl-s1">i</span> <span class="pl-c1">&lt;</span> <span class="pl-s1">sourceKeys</span><span class="pl-kos">.</span><span class="pl-c1">length</span><span class="pl-kos">;</span> <span class="pl-s1">i</span><span class="pl-c1">++</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-s1">key</span> <span class="pl-c1">=</span> <span class="pl-s1">sourceKeys</span><span class="pl-kos">[</span><span class="pl-s1">i</span><span class="pl-kos">]</span><span class="pl-kos">;</span> <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">excluded</span><span class="pl-kos">.</span><span class="pl-en">indexOf</span><span class="pl-kos">(</span><span class="pl-s1">key</span><span class="pl-kos">)</span> <span class="pl-c1">&gt;=</span> <span class="pl-c1">0</span><span class="pl-kos">)</span> <span class="pl-k">continue</span><span class="pl-kos">;</span> <span class="pl-s1">target</span><span class="pl-kos">[</span><span class="pl-s1">key</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-s1">source</span><span class="pl-kos">[</span><span class="pl-s1">key</span><span class="pl-kos">]</span><span class="pl-kos">;</span> <span class="pl-kos">}</span> <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-v">Object</span><span class="pl-kos">.</span><span class="pl-c1">getOwnPropertySymbols</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">var</span> <span class="pl-s1">sourceSymbolKeys</span> <span class="pl-c1">=</span> <span class="pl-v">Object</span><span class="pl-kos">.</span><span class="pl-en">getOwnPropertySymbols</span><span class="pl-kos">(</span><span class="pl-s1">source</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-k">for</span> <span class="pl-kos">(</span><span class="pl-s1">i</span> <span class="pl-c1">=</span> <span class="pl-c1">0</span><span class="pl-kos">;</span> <span class="pl-s1">i</span> <span class="pl-c1">&lt;</span> <span class="pl-s1">sourceSymbolKeys</span><span class="pl-kos">.</span><span class="pl-c1">length</span><span class="pl-kos">;</span> <span class="pl-s1">i</span><span class="pl-c1">++</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-s1">key</span> <span class="pl-c1">=</span> <span class="pl-s1">sourceSymbolKeys</span><span class="pl-kos">[</span><span class="pl-s1">i</span><span class="pl-kos">]</span><span class="pl-kos">;</span> <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">excluded</span><span class="pl-kos">.</span><span class="pl-en">indexOf</span><span class="pl-kos">(</span><span class="pl-s1">key</span><span class="pl-kos">)</span> <span class="pl-c1">&gt;=</span> <span class="pl-c1">0</span><span class="pl-kos">)</span> <span class="pl-k">continue</span><span class="pl-kos">;</span> <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-c1">!</span><span class="pl-v">Object</span><span class="pl-kos">.</span><span class="pl-c1">prototype</span><span class="pl-kos">.</span><span class="pl-c1">propertyIsEnumerable</span><span class="pl-kos">.</span><span class="pl-en">call</span><span class="pl-kos">(</span><span class="pl-s1">source</span><span class="pl-kos">,</span> <span class="pl-s1">key</span><span class="pl-kos">)</span><span class="pl-kos">)</span> <span class="pl-k">continue</span><span class="pl-kos">;</span> <span class="pl-s1">target</span><span class="pl-kos">[</span><span class="pl-s1">key</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-s1">source</span><span class="pl-kos">[</span><span class="pl-s1">key</span><span class="pl-kos">]</span><span class="pl-kos">;</span> <span class="pl-kos">}</span> <span class="pl-kos">}</span> <span class="pl-k">return</span> <span class="pl-s1">target</span><span class="pl-kos">;</span> <span class="pl-kos">}</span>

<span class="pl-k">const</span> <span class="pl-s1">rest1</span> <span class="pl-c1">=</span> <span class="pl-en">_objectWithoutProperties</span><span class="pl-kos">(</span><span class="pl-kos">{</span><span class="pl-kos">}</span><span class="pl-kos">,</span> <span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-k">const</span> <span class="pl-kos">[</span><span class="pl-kos">{</span> ...<span class="pl-s1">rest2</span>
<span class="pl-kos">}</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-kos">[</span><span class="pl-kos">{</span><span class="pl-kos">}</span><span class="pl-kos">]</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">Notice how <code class="notranslate">...rest1</code> got transformed but <code class="notranslate">...rest2</code> is left intact.</p>
<p dir="auto">I expect that <code class="notranslate">...rest2</code> is also transformed.</p>
<hr>
<p dir="auto">Original issue where this got reported: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="286180365" data-permission-text="Title is private" data-url="https://github.com/facebook/create-react-app/issues/3694" data-hovercard-type="issue" data-hovercard-url="/facebook/create-react-app/issues/3694/hovercard" href="https://github.com/facebook/create-react-app/issues/3694">facebook/create-react-app#3694</a></p>