<h3 dir="auto"><g-emoji class="g-emoji" alias="computer" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f4bb.png">💻</g-emoji></h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Would you like to work on a fix?</li>
</ul>
<h3 dir="auto">How are you using Babel?</h3>
<p dir="auto">@babel/cli</p>
<h3 dir="auto">Input code</h3>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="type key = null;

export function schema(schema) {
	for (const key in obj) {
		const subpath = key ? `${key}.test` : null;
		if (typeof obj[key] === 'string') {
			result[key] = (a) =&gt; t(subpath, a);
		} else {
			result[key] = toFunc(obj[key], subpath);
		}
	}
}"><pre class="notranslate"><span class="pl-k">type</span> <span class="pl-smi">key</span> <span class="pl-c1">=</span> <span class="pl-c1">null</span><span class="pl-kos">;</span>

<span class="pl-k">export</span> <span class="pl-k">function</span> <span class="pl-en">schema</span><span class="pl-kos">(</span><span class="pl-s1">schema</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-k">const</span> <span class="pl-s1">key</span> <span class="pl-k">in</span> <span class="pl-s1">obj</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
		<span class="pl-k">const</span> <span class="pl-s1">subpath</span> <span class="pl-c1">=</span> <span class="pl-s1">key</span> ? <span class="pl-s">`<span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">key</span><span class="pl-kos">}</span></span>.test`</span> : <span class="pl-c1">null</span><span class="pl-kos">;</span>
		<span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-k">typeof</span> <span class="pl-s1">obj</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-s">'string'</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
			<span class="pl-s1">result</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-kos">(</span><span class="pl-s1">a</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-en">t</span><span class="pl-kos">(</span><span class="pl-s1">subpath</span><span class="pl-kos">,</span> <span class="pl-s1">a</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
		<span class="pl-kos">}</span> <span class="pl-k">else</span> <span class="pl-kos">{</span>
			<span class="pl-s1">result</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-en">toFunc</span><span class="pl-kos">(</span><span class="pl-s1">obj</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">subpath</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>
<h3 dir="auto">Configuration file name</h3>
<p dir="auto">babel.config.js</p>
<h3 dir="auto">Configuration</h3>
<p dir="auto">babel.config.js</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
  &quot;presets&quot;: [
    &quot;@babel/env&quot;,
    &quot;@babel/typescript&quot;
  ]
}"><pre class="notranslate"><span class="pl-kos">{</span>
  <span class="pl-s">"presets"</span>: <span class="pl-kos">[</span>
    <span class="pl-s">"@babel/env"</span><span class="pl-kos">,</span>
    <span class="pl-s">"@babel/typescript"</span>
  <span class="pl-kos">]</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">.babelrc.json</p>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
  &quot;presets&quot;: [
    [
      &quot;react-app&quot;,
      {
        &quot;runtime&quot;: &quot;automatic&quot;,
        &quot;flow&quot;: false
      }
    ]
  ],
  &quot;plugins&quot;: []
}"><pre class="notranslate">{
  <span class="pl-ent">"presets"</span>: [
    [
      <span class="pl-s"><span class="pl-pds">"</span>react-app<span class="pl-pds">"</span></span>,
      {
        <span class="pl-ent">"runtime"</span>: <span class="pl-s"><span class="pl-pds">"</span>automatic<span class="pl-pds">"</span></span>,
        <span class="pl-ent">"flow"</span>: <span class="pl-c1">false</span>
      }
    ]
  ],
  <span class="pl-ent">"plugins"</span>: []
}</pre></div>
<h3 dir="auto">Current and expected behavior</h3>
<p dir="auto">It seems typescript typings are affecting the generated babel output. I was able to reproduce the issue on the babel repl:</p>
<p dir="auto">in the input code <code class="notranslate">type key = null</code></p>
<p dir="auto"><a href="https://babeljs.io/repl#?browsers=defaults%2C%20not%20ie%2011%2C%20not%20ie_mob%2011&amp;build=&amp;builtIns=false&amp;corejs=false&amp;spec=false&amp;loose=false&amp;code_lz=C4TwDgpgBA1hJQLxQHYFcA2GDcAoXEAHmAPYBOwUAZmigMbACWJKUAznQBYQC2AhgAoO3fgEooAb1wBIKuSgC6LNpTgJGrEgCMAVuKnTpSlCvZotYPsE5JY8KAH4oAAwAkEtQF8AdMAgrnKAAuVEwcGWlGKgVQSBJo7R0AbTUAXSREZAByFTINAHMs_QjpMn9MYBT4dOQBPnFEAD4oYCFzS2sAGih6vENPKAgMNmgDQzK2CqqQGpaSADFaOgFE6dTuyYsrTlE-6U8ZA4OgA&amp;debug=false&amp;forceAllTransforms=true&amp;shippedProposals=false&amp;circleciRepo=&amp;evaluate=false&amp;fileSize=false&amp;timeTravel=false&amp;sourceType=module&amp;lineWrap=true&amp;presets=env%2Ctypescript&amp;prettier=false&amp;targets=&amp;version=7.20.13&amp;externalPlugins=babel-plugin-styled-components%402.0.7%2Cbabel-plugin-lodash%403.3.4&amp;assumptions=%7B%7D" rel="nofollow">https://babeljs.io/repl#?browsers=defaults%2C%20not%20ie%2011%2C%20not%20ie_mob%2011&amp;build=&amp;builtIns=false&amp;corejs=false&amp;spec=false&amp;loose=false&amp;code_lz=C4TwDgpgBA1hJQLxQHYFcA2GDcAoXEAHmAPYBOwUAZmigMbACWJKUAznQBYQC2AhgAoO3fgEooAb1wBIKuSgC6LNpTgJGrEgCMAVuKnTpSlCvZotYPsE5JY8KAH4oAAwAkEtQF8AdMAgrnKAAuVEwcGWlGKgVQSBJo7R0AbTUAXSREZAByFTINAHMs_QjpMn9MYBT4dOQBPnFEAD4oYCFzS2sAGih6vENPKAgMNmgDQzK2CqqQGpaSADFaOgFE6dTuyYsrTlE-6U8ZA4OgA&amp;debug=false&amp;forceAllTransforms=true&amp;shippedProposals=false&amp;circleciRepo=&amp;evaluate=false&amp;fileSize=false&amp;timeTravel=false&amp;sourceType=module&amp;lineWrap=true&amp;presets=env%2Ctypescript&amp;prettier=false&amp;targets=&amp;version=7.20.13&amp;externalPlugins=babel-plugin-styled-components%402.0.7%2Cbabel-plugin-lodash%403.3.4&amp;assumptions=%7B%7D</a></p>
<p dir="auto">after changing <code class="notranslate">type key = null</code> to <code class="notranslate">type key2 = null</code></p>
<p dir="auto"><a href="https://babeljs.io/repl#?browsers=defaults%2C%20not%20ie%2011%2C%20not%20ie_mob%2011&amp;build=&amp;builtIns=false&amp;corejs=false&amp;spec=false&amp;loose=false&amp;code_lz=C4TwDgpgBA1hICYoF4oDsCuAbLBuAUPhAB5gD2ATsFAGYZoDGwAlmWlAM4MAWEAtgEMAFF16CAlFADe-AJA1KUIQzYdqcEFGbsyAIwBWkmbNkq0azhl1gBwbiljwoAfigADACRSNAXwB0wBBqblAAXOjYeHKyzDRKoJBkcXr6ANoaALooyKgA5GoU2gDmuUbRshRB2MDp8FmoQgKSyAB8UMAiVjZ2ADRQTQQmPlAQWBzQxiaVHNW1IPXtZABi9AxCKXMZfTPWttzig7I-csfHQA&amp;debug=false&amp;forceAllTransforms=true&amp;shippedProposals=false&amp;circleciRepo=&amp;evaluate=false&amp;fileSize=false&amp;timeTravel=false&amp;sourceType=module&amp;lineWrap=true&amp;presets=env%2Ctypescript&amp;prettier=false&amp;targets=&amp;version=7.20.13&amp;externalPlugins=babel-plugin-styled-components%402.0.7%2Cbabel-plugin-lodash%403.3.4&amp;assumptions=%7B%7D" rel="nofollow">https://babeljs.io/repl#?browsers=defaults%2C%20not%20ie%2011%2C%20not%20ie_mob%2011&amp;build=&amp;builtIns=false&amp;corejs=false&amp;spec=false&amp;loose=false&amp;code_lz=C4TwDgpgBA1hICYoF4oDsCuAbLBuAUPhAB5gD2ATsFAGYZoDGwAlmWlAM4MAWEAtgEMAFF16CAlFADe-AJA1KUIQzYdqcEFGbsyAIwBWkmbNkq0azhl1gBwbiljwoAfigADACRSNAXwB0wBBqblAAXOjYeHKyzDRKoJBkcXr6ANoaALooyKgA5GoU2gDmuUbRshRB2MDp8FmoQgKSyAB8UMAiVjZ2ADRQTQQmPlAQWBzQxiaVHNW1IPXtZABi9AxCKXMZfTPWttzig7I-csfHQA&amp;debug=false&amp;forceAllTransforms=true&amp;shippedProposals=false&amp;circleciRepo=&amp;evaluate=false&amp;fileSize=false&amp;timeTravel=false&amp;sourceType=module&amp;lineWrap=true&amp;presets=env%2Ctypescript&amp;prettier=false&amp;targets=&amp;version=7.20.13&amp;externalPlugins=babel-plugin-styled-components%402.0.7%2Cbabel-plugin-lodash%403.3.4&amp;assumptions=%7B%7D</a></p>
<p dir="auto">The first link results in invalid code.</p>
<p dir="auto">In this case it seems the <code class="notranslate">key</code> symbol from the type definition is interfering with the js code and causing duplicate symbols</p>
<h3 dir="auto">Environment</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="@babel/core: ^7.20.12 =&gt; 7.20.12 
@babel/preset-env: ^7.20.2 =&gt; 7.20.2 
@babel/preset-react: ^7.18.6 =&gt; 7.18.6 
@babel/preset-typescript: ^7.18.6 =&gt; 7.18.6 
babel-polyfill: ^6.26.0 =&gt; 6.26.0 
babel-preset-react-app: ^10.0.1 =&gt; 10.0.1 

Node: 16.15.0
npm: 8.10.0

OS: Linux"><pre class="notranslate"><code class="notranslate">@babel/core: ^7.20.12 =&gt; 7.20.12 
@babel/preset-env: ^7.20.2 =&gt; 7.20.2 
@babel/preset-react: ^7.18.6 =&gt; 7.18.6 
@babel/preset-typescript: ^7.18.6 =&gt; 7.18.6 
babel-polyfill: ^6.26.0 =&gt; 6.26.0 
babel-preset-react-app: ^10.0.1 =&gt; 10.0.1 

Node: 16.15.0
npm: 8.10.0

OS: Linux
</code></pre></div>
<h3 dir="auto">Possible solution</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Additional context</h3>
<p dir="auto">This started happening after upgrading to babel latest version</p>
<h3 dir="auto"><g-emoji class="g-emoji" alias="computer" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f4bb.png">💻</g-emoji></h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Would you like to work on a fix?</li>
</ul>
<h3 dir="auto">How are you using Babel?</h3>
<p dir="auto">Programmatic API (<code class="notranslate">babel.transform</code>, <code class="notranslate">babel.parse</code>)</p>
<h3 dir="auto">Input code</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="const test = (data) =&gt; {
  for (let i = 0; i &lt; data.length; i++) {
    const x = data[i];
    data.find((item) =&gt; item === x);
  }
  for (let i = 0; i &lt; data.length; i++) {
    const x = data[i];
    data.find((item) =&gt; item === x);
  }
}"><pre class="notranslate"><code class="notranslate">const test = (data) =&gt; {
  for (let i = 0; i &lt; data.length; i++) {
    const x = data[i];
    data.find((item) =&gt; item === x);
  }
  for (let i = 0; i &lt; data.length; i++) {
    const x = data[i];
    data.find((item) =&gt; item === x);
  }
}
</code></pre></div>
<h3 dir="auto">Configuration file name</h3>
<p dir="auto">.babelrc</p>
<h3 dir="auto">Configuration</h3>
<p dir="auto">{<br>
"presets": [<br>
"@babel/preset-env"<br>
]<br>
}</p>
<h3 dir="auto">Current and expected behavior</h3>
<p dir="auto">current output:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&quot;use strict&quot;;

var test = function test(data) {
  var _loop = function _loop() {
    var x = data[i];
    data.find(function (item) {
      return item === x;
    });
  };
  for (var i = 0; i &lt; data.length; i++) {
    _loop();
  }
  var _loop2 = function _loop2() {
    var x = data[i];
    data.find(function (item) {
      return item === x;
    });
  };
  for (var _i = 0; _i &lt; data.length; _i++) {
    _loop2();
  }
};"><pre class="notranslate"><code class="notranslate">"use strict";

var test = function test(data) {
  var _loop = function _loop() {
    var x = data[i];
    data.find(function (item) {
      return item === x;
    });
  };
  for (var i = 0; i &lt; data.length; i++) {
    _loop();
  }
  var _loop2 = function _loop2() {
    var x = data[i];
    data.find(function (item) {
      return item === x;
    });
  };
  for (var _i = 0; _i &lt; data.length; _i++) {
    _loop2();
  }
};
</code></pre></div>
<p dir="auto">the second <code class="notranslate">var x = data[i];</code> should be <code class="notranslate">var x = data[_i];</code></p>
<h3 dir="auto">Environment</h3>
<p dir="auto">System:<br>
OS: macOS 12.6.2<br>
Binaries:<br>
Node: 14.19.0 - /usr/local/bin/node<br>
Yarn: 1.22.17 - /usr/local/bin/yarn<br>
npm: 6.14.16 - /usr/local/bin/npm<br>
npmPackages:<br>
@babel/cli: ^7.17.6 =&gt; 7.17.6<br>
@babel/core: ^7.20.7 =&gt; 7.20.7<br>
@babel/node: ^7.16.8 =&gt; 7.16.8<br>
@babel/plugin-transform-block-scoping: ^7.20.9 =&gt; 7.20.9<br>
@babel/preset-env: ^7.16.11 =&gt; 7.16.11</p>
<h3 dir="auto">Possible solution</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Additional context</h3>
<p dir="auto"><em>No response</em></p>