<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>
<p dir="auto">`class Test {</p>
<p dir="auto">foo() {</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="  var self = this;

  var checkWithUserPromise = new Promise(function (resolve) {

    self.userInputComplete = resolve;

    console.log('--------------');

    document.getElementById('Dialog').open();

  });

  return checkWithUserPromise;

}"><pre class="notranslate"><code class="notranslate">  var self = this;

  var checkWithUserPromise = new Promise(function (resolve) {

    self.userInputComplete = resolve;

    console.log('--------------');

    document.getElementById('Dialog').open();

  });

  return checkWithUserPromise;

}
</code></pre></div>
<p dir="auto">}`</p>
<h3 dir="auto">Configuration file name</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Configuration</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Current and expected behavior</h3>
<p dir="auto">Transpiled code used to be</p>
<p dir="auto"><code class="notranslate">checkWithUserForItemOrgAssociation(){var a=this,b=new Promise(function(b){a.userInputComplete=b,console.log("--------------"),document.getElementById("Dialog").open()});return b} </code></p>
<p dir="auto">since @babel/transform 7.17.10 it is transpiled to</p>
<p dir="auto"><code class="notranslate">checkWithUserForItemOrgAssociation(){var a=new Promise(function(a){this.userInputComplete=a,console.log("--------------"),document.getElementById("Dialog").open()});return a}</code></p>
<p dir="auto">which is obviously wrong.</p>
<h3 dir="auto">Environment</h3>
<p dir="auto">node v16.13.0<br>
npm 8.1.0<br>
@babel/core 7.17.10<br>
babel-preset-minify: 0.5.1</p>
<h3 dir="auto">Possible solution</h3>
<p dir="auto">I had to use npm-shrinkwrap.json to enforce older @babel/transform sub dependency of @babel/core</p>
<h3 dir="auto">Additional context</h3>
<p dir="auto"><em>No response</em></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">@babel/cli</p>
<h3 dir="auto">Input code</h3>
<p dir="auto">Reproduced in <a href="https://babel.dev/repl#?browsers=defaults%2C%20not%20ie%2011%2C%20not%20ie_mob%2011&amp;build=&amp;builtIns=false&amp;corejs=3.21&amp;spec=false&amp;loose=false&amp;code_lz=MYGwhgzhAEBiD28BGYBO0DeAoa1jwDsIAXVAV2GPlQAoBKTHXaYgCwEsIA6AM0RXQBeaABYATAG4muGvWiCAfI2bN2PaDTade_NNACEg4eIbYVKtqngB3aAQCmtgKKortAORaYfZGnsATdzopc2gAX2lwunoQ8KwI_CJiaB95O0c4XVpgrCA&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=false&amp;presets=env&amp;prettier=false&amp;targets=&amp;version=7.17.11&amp;externalPlugins=babel-plugin-minify-dead-code-elimination%400.5.1&amp;assumptions=%7B%7D" rel="nofollow">Babel REPL</a>.</p>
<h3 dir="auto">Configuration file name</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Configuration</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Current and expected behavior</h3>
<p dir="auto">Enabling <code class="notranslate">babel-plugin-minify-dead-code-elimination</code> plugin destroys <code class="notranslate">this</code> scope for arrow functions inside classes.</p>
<p dir="auto">The <code class="notranslate">var _this = this</code> workaround should not be eliminated as it is absolutely necessary for the <code class="notranslate">this</code> scope to work in locally defined arrow functions.</p>
<h3 dir="auto">Environment</h3>
<ul dir="auto">
<li>Babel version v7.17.11</li>
</ul>
<h3 dir="auto">Possible solution</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Additional context</h3>
<p dir="auto">I narrowed the problem down locally to <code class="notranslate">@babel/traverse</code> v7.17.10. By reverting that package to v7.17.9 this problem does not occur.</p>