<h2 dir="auto">Bug Report</h2>
<p dir="auto"><strong>Current Behavior</strong><br>
When setting a value to an object using a dynamic + numeric key<br>
The key is converted to a string (expected)<br>
When I then use destructuring to receive the value it works using the numeric key<br>
When I also take the <code class="notranslate">...rest</code> of the object<br>
Then I expect the rest not to contain the previously destructured key</p>
<p dir="auto">BUT the key is still present in the rest</p>
<p dir="auto"><strong>Input Code</strong><br>
<a href="https://babeljs.io/repl#?babili=true&amp;browsers=&amp;build=&amp;builtIns=false&amp;spec=false&amp;loose=false&amp;code_lz=MYewdgzgLgBA1gUwJ4wLwwEwG4BQpKzQCGUCaMA3jANqJIC6AXDAOQBmIILANDAEZEATsxYCAXixgBfXPmiUadJjAAOAGwCuwOLwB0-wQnlTyxUrPDyq1AMpRBASzABzABR0AlMvVa4GPQZGUBjSplAkCBaQIGoIukQQEAiCUK44MDBQSCoIIGwwAPJ8AFYIwFC6dBCuZgge1AAM9Gio6CzQji486TAABgCiAB455QgAJjAAJBRFpeWVyNW19U0mUCD8ZEQwHU7OvTgeeJYxcQlJKWkZPtot6Dd-3D0Dw2WkE9MPaxt8ZJ-a2gwUgORwA9KCYAAVAAWDggMDYRAcaggjGO0Vi8USyVSPVmbwWSGqhmgHl0sRcUGhd0KJQJVVcJOCZIpzipTwyLxG7ymFAAUjYCgA5XS7FwONhIRlBDzfGAIACOGiIal5AuFovsewlUqZGFlIKAA&amp;debug=false&amp;forceAllTransforms=false&amp;shippedProposals=false&amp;circleciRepo=&amp;evaluate=true&amp;fileSize=false&amp;timeTravel=false&amp;sourceType=module&amp;lineWrap=false&amp;presets=es2015%2Cstage-2%2Cbabili&amp;prettier=false&amp;targets=&amp;version=6.26.0&amp;envVersion=" rel="nofollow">REPL link (See console)</a></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="const key = 2;
const state = { [key]: 'foo', bar: 'baz' };
const { [key]: pluck, ...rest } = state;
const { [String(key)]: pluck2, ...rest2 } = state;
console.assert(
  typeof Object.keys(state)[0] === 'string',
  `Expected ${Object.keys(state)[0]} to be a string`
)
console.assert(
  pluck === pluck2,
  `Expected ${pluck} to be ${pluck2}`
)
// This fails:
console.assert(
  Object.keys(rest).length === Object.keys(rest2).length,
  `Expected ${JSON.stringify(rest)} to equal ${JSON.stringify(rest2)}`
)"><pre class="notranslate"><span class="pl-k">const</span> <span class="pl-s1">key</span> <span class="pl-c1">=</span> <span class="pl-c1">2</span><span class="pl-kos">;</span>
<span class="pl-k">const</span> <span class="pl-s1">state</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-kos">]</span>: <span class="pl-s">'foo'</span><span class="pl-kos">,</span> <span class="pl-c1">bar</span>: <span class="pl-s">'baz'</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">key</span><span class="pl-kos">]</span>: <span class="pl-s1">pluck</span><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">state</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-v">String</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-s1">pluck2</span><span class="pl-kos">,</span> ...<span class="pl-s1">rest2</span> <span class="pl-kos">}</span> <span class="pl-c1">=</span> <span class="pl-s1">state</span><span class="pl-kos">;</span>
<span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">assert</span><span class="pl-kos">(</span>
  <span class="pl-k">typeof</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">state</span><span class="pl-kos">)</span><span class="pl-kos">[</span><span class="pl-c1">0</span><span class="pl-kos">]</span> <span class="pl-c1">===</span> <span class="pl-s">'string'</span><span class="pl-kos">,</span>
  <span class="pl-s">`Expected <span class="pl-s1"><span class="pl-kos">${</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">state</span><span class="pl-kos">)</span><span class="pl-kos">[</span><span class="pl-c1">0</span><span class="pl-kos">]</span><span class="pl-kos">}</span></span> to be a string`</span>
<span class="pl-kos">)</span>
<span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">assert</span><span class="pl-kos">(</span>
  <span class="pl-s1">pluck</span> <span class="pl-c1">===</span> <span class="pl-s1">pluck2</span><span class="pl-kos">,</span>
  <span class="pl-s">`Expected <span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">pluck</span><span class="pl-kos">}</span></span> to be <span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">pluck2</span><span class="pl-kos">}</span></span>`</span>
<span class="pl-kos">)</span>
<span class="pl-c">// This fails:</span>
<span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">assert</span><span class="pl-kos">(</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">rest</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-c1">length</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">rest2</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-c1">length</span><span class="pl-kos">,</span>
  <span class="pl-s">`Expected <span class="pl-s1"><span class="pl-kos">${</span><span class="pl-c1">JSON</span><span class="pl-kos">.</span><span class="pl-en">stringify</span><span class="pl-kos">(</span><span class="pl-s1">rest</span><span class="pl-kos">)</span><span class="pl-kos">}</span></span> to equal <span class="pl-s1"><span class="pl-kos">${</span><span class="pl-c1">JSON</span><span class="pl-kos">.</span><span class="pl-en">stringify</span><span class="pl-kos">(</span><span class="pl-s1">rest2</span><span class="pl-kos">)</span><span class="pl-kos">}</span></span>`</span>
<span class="pl-kos">)</span></pre></div>
<p dir="auto"><strong>Expected behavior/code</strong></p>
<ol dir="auto">
<li>The destructured key should not be contained in rest even if a numeric key is used for destructuring</li>
<li>The assertions in above code should not throw when code is transpiled with babel and evaluated</li>
</ol>
<p dir="auto"><strong>Babel Configuration (.babelrc, package.json, cli command)</strong></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
  &quot;presets&quot;: [&quot;preset-stage-3&quot;]
}"><pre class="notranslate"><span class="pl-kos">{</span>
  <span class="pl-s">"presets"</span>: <span class="pl-kos">[</span><span class="pl-s">"preset-stage-3"</span><span class="pl-kos">]</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto"><strong>Environment</strong></p>
<ul dir="auto">
<li>Babel version(s): <code class="notranslate">v6.26.0</code> (REPL), <code class="notranslate">v7.2.2</code> (my machine)</li>
<li>Node/npm version: Node 11.4.0/npm 6.4.1</li>
<li>OS: MacOS 10.14.1</li>
<li>Monorepo: 🤷‍♂️</li>
<li>How you are using Babel: loader</li>
</ul>
<p dir="auto"><strong>Additional context/Screenshots</strong><br>
Works as expected in Chrome + Firefox Console</p>
<p dir="auto">Choose one: is this a bug report or feature request?<br>
bug</p>

<h3 dir="auto">Input Code</h3>


<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="const a = { 1: 0, 2: 1, 3: 2 }
const i = 1
const { [i]: val, ...rest } = a"><pre class="notranslate"><span class="pl-k">const</span> <span class="pl-s1">a</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span> <span class="pl-c1">1</span>: <span class="pl-c1">0</span><span class="pl-kos">,</span> <span class="pl-c1">2</span>: <span class="pl-c1">1</span><span class="pl-kos">,</span> <span class="pl-c1">3</span>: <span class="pl-c1">2</span> <span class="pl-kos">}</span>
<span class="pl-k">const</span> <span class="pl-s1">i</span> <span class="pl-c1">=</span> <span class="pl-c1">1</span>
<span class="pl-k">const</span> <span class="pl-kos">{</span> <span class="pl-kos">[</span><span class="pl-s1">i</span><span class="pl-kos">]</span>: <span class="pl-s1">val</span><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">a</span></pre></div>
<h3 dir="auto">Babel Configuration (.babelrc, package.json, cli command)</h3>

<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
  &quot;presets&quot;: [&quot;babel-preset-expo&quot;],
  &quot;env&quot;: {
    &quot;development&quot;: {
      &quot;plugins&quot;: [&quot;transform-react-jsx-source&quot;]
    }
  }
}"><pre class="notranslate">{
  <span class="pl-ent">"presets"</span>: [<span class="pl-s"><span class="pl-pds">"</span>babel-preset-expo<span class="pl-pds">"</span></span>],
  <span class="pl-ent">"env"</span>: {
    <span class="pl-ent">"development"</span>: {
      <span class="pl-ent">"plugins"</span>: [<span class="pl-s"><span class="pl-pds">"</span>transform-react-jsx-source<span class="pl-pds">"</span></span>]
    }
  }
}</pre></div>
<h3 dir="auto">Expected Behavior</h3>


<p dir="auto">rest should be</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
  &quot;2&quot;: 1,
  &quot;3&quot;: 2,
}"><pre class="notranslate"><span class="pl-kos">{</span>
  <span class="pl-s">"2"</span>: <span class="pl-c1">1</span><span class="pl-kos">,</span>
  <span class="pl-s">"3"</span>: <span class="pl-c1">2</span><span class="pl-kos">,</span>
<span class="pl-kos">}</span></pre></div>
<h3 dir="auto">Current Behavior</h3>


<p dir="auto">rest is</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
  &quot;1&quot;: 0,
  &quot;2&quot;: 1,
  &quot;3&quot;: 2,
}"><pre class="notranslate"><span class="pl-kos">{</span>
  <span class="pl-s">"1"</span>: <span class="pl-c1">0</span><span class="pl-kos">,</span>
  <span class="pl-s">"2"</span>: <span class="pl-c1">1</span><span class="pl-kos">,</span>
  <span class="pl-s">"3"</span>: <span class="pl-c1">2</span><span class="pl-kos">,</span>
<span class="pl-kos">}</span></pre></div>
<h3 dir="auto">Possible Solution</h3>


<p dir="auto">indexOf compares with 3 equals and the object key is represented as string<br>
</p><div class="Box Box--condensed my-2">
  <div class="Box-header f6">
    <p class="mb-0 text-bold">
      <a href="https://github.com/babel/babel/blob/88b7983e4f1b4d472f37c057afce0e86da7feb0b/packages/babel-helpers/src/helpers.js#L469">babel/packages/babel-helpers/src/helpers.js</a>
    </p>
    <p class="mb-0 color-fg-muted">
         Line 469
      in
      <a data-pjax="true" class="commit-tease-sha" href="/babel/babel/commit/88b7983e4f1b4d472f37c057afce0e86da7feb0b">88b7983</a>
    </p>
  </div>
  <div itemprop="text" class="Box-body p-0 blob-wrapper blob-wrapper-embedded data">
    <table class="highlight tab-size mb-0 js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">

        <tbody><tr class="border-0">
          <td id="L469" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="469"></td>
          <td id="LC469" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-s">      if (excluded.indexOf(key) &gt;= 0) continue;</span> </td>
        </tr>
    </tbody></table>
  </div>
</div>
<p></p>
<h3 dir="auto">Context</h3>


<p dir="auto">running react-native application</p>
<h3 dir="auto">Your Environment</h3>

<p dir="auto">using react native with expo</p>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
  &quot;expo&quot;: {
    &quot;sdkVersion&quot;: &quot;21.0.0&quot;
  }
}"><pre class="notranslate">{
  <span class="pl-ent">"expo"</span>: {
    <span class="pl-ent">"sdkVersion"</span>: <span class="pl-s"><span class="pl-pds">"</span>21.0.0<span class="pl-pds">"</span></span>
  }
}</pre></div>
<p dir="auto">dont know about configuration</p>