<h3 dir="auto">💻</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">Other (Next.js, Gatsby, vue-cli, ...)</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="var Icestore = /** @class */ (function () {
  function Icestore(config) {
      var _this = this;
      // preStore: middleware, model hooks
      this.forEachPlugin('middleware', function (middleware) {
          _this.config.redux.middlewares.push(middleware);
      });
  }

  return Icestore;
}());"><pre class="notranslate"><span class="pl-k">var</span> <span class="pl-v">Icestore</span> <span class="pl-c1">=</span> <span class="pl-c">/** <span class="pl-k">@class</span> */</span> <span class="pl-kos">(</span><span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
  <span class="pl-k">function</span> <span class="pl-v">Icestore</span><span class="pl-kos">(</span><span class="pl-s1">config</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
      <span class="pl-k">var</span> <span class="pl-s1">_this</span> <span class="pl-c1">=</span> <span class="pl-smi">this</span><span class="pl-kos">;</span>
      <span class="pl-c">// preStore: middleware, model hooks</span>
      <span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-en">forEachPlugin</span><span class="pl-kos">(</span><span class="pl-s">'middleware'</span><span class="pl-kos">,</span> <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-s1">middleware</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
          <span class="pl-s1">_this</span><span class="pl-kos">.</span><span class="pl-c1">config</span><span class="pl-kos">.</span><span class="pl-c1">redux</span><span class="pl-kos">.</span><span class="pl-c1">middlewares</span><span class="pl-kos">.</span><span class="pl-en">push</span><span class="pl-kos">(</span><span class="pl-s1">middleware</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">return</span> <span class="pl-v">Icestore</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></pre></div>
<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>
<h2 dir="auto">Current</h2>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="var Icestore = /** @class */ (function () {
  function Icestore(config) {

      // preStore: middleware, model hooks
      this.forEachPlugin('middleware', function (middleware) {
          this.config.redux.middlewares.push(middleware);
      });
  }

  return Icestore;
}());"><pre class="notranslate"><span class="pl-k">var</span> <span class="pl-v">Icestore</span> <span class="pl-c1">=</span> <span class="pl-c">/** <span class="pl-k">@class</span> */</span> <span class="pl-kos">(</span><span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
  <span class="pl-k">function</span> <span class="pl-v">Icestore</span><span class="pl-kos">(</span><span class="pl-s1">config</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>

      <span class="pl-c">// preStore: middleware, model hooks</span>
      <span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-en">forEachPlugin</span><span class="pl-kos">(</span><span class="pl-s">'middleware'</span><span class="pl-kos">,</span> <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-s1">middleware</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
          <span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-c1">config</span><span class="pl-kos">.</span><span class="pl-c1">redux</span><span class="pl-kos">.</span><span class="pl-c1">middlewares</span><span class="pl-kos">.</span><span class="pl-en">push</span><span class="pl-kos">(</span><span class="pl-s1">middleware</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">return</span> <span class="pl-v">Icestore</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></pre></div>
<h2 dir="auto">Expected</h2>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="var Icestore = /** @class */ (function () {
  function Icestore(config) {
      var _this = this;
      // preStore: middleware, model hooks
      this.forEachPlugin('middleware', function (middleware) {
          _this.config.redux.middlewares.push(middleware);
      });
  }

  return Icestore;
}());"><pre class="notranslate"><span class="pl-k">var</span> <span class="pl-v">Icestore</span> <span class="pl-c1">=</span> <span class="pl-c">/** <span class="pl-k">@class</span> */</span> <span class="pl-kos">(</span><span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
  <span class="pl-k">function</span> <span class="pl-v">Icestore</span><span class="pl-kos">(</span><span class="pl-s1">config</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
      <span class="pl-k">var</span> <span class="pl-s1">_this</span> <span class="pl-c1">=</span> <span class="pl-smi">this</span><span class="pl-kos">;</span>
      <span class="pl-c">// preStore: middleware, model hooks</span>
      <span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-en">forEachPlugin</span><span class="pl-kos">(</span><span class="pl-s">'middleware'</span><span class="pl-kos">,</span> <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-s1">middleware</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
          <span class="pl-s1">_this</span><span class="pl-kos">.</span><span class="pl-c1">config</span><span class="pl-kos">.</span><span class="pl-c1">redux</span><span class="pl-kos">.</span><span class="pl-c1">middlewares</span><span class="pl-kos">.</span><span class="pl-en">push</span><span class="pl-kos">(</span><span class="pl-s1">middleware</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">return</span> <span class="pl-v">Icestore</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></pre></div>
<h3 dir="auto">Environment</h3>
<p dir="auto">@babel/traverse 7.17.10</p>
<p dir="auto">I rollbacked to 7.17.9, it worked.</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>
<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>