<h2 dir="auto">Bug Report</h2>

<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I would like to work on a fix!<br>
I have close to zero experience with Babel's internals though. I would not be offended, if you think you can fix it yourself quicklier.</li>
</ul>

<p dir="auto"><strong>Current Behavior</strong><br>
The <code class="notranslate">typescript</code> preset is incompatible with <a href="https://github.com/d3/d3-array/blob/master/src/cumsum.js"><code class="notranslate">d3-array/cumsum.js</code></a>. The issue seems to only occur for arrow functions using the <code class="notranslate">+=</code> operator, nested inside a ternary. When <code class="notranslate">typescript</code> is disabled, the code compiled without any issues.</p>
<p dir="auto"><strong>Input Code</strong></p>
<ul dir="auto">
<li>Original broken <code class="notranslate">d3-array/cumsum.js</code>: <a href="https://babeljs.io/en/repl#?browsers=&amp;build=&amp;builtIns=false&amp;spec=false&amp;loose=true&amp;code_lz=KYDwDg9gTgLgBAE2AMwIYFcA29noHYDGMAlhHnAegLYDO1AFAG6qbrA0A0czrwEyASjgBvAFBxuqKHDpU4AXjgAGLsTxIQC5QG5xcKMBjoo5AGKYIqGADYALAEEoUVAE8AdMigQqTFm06SvPwK8or4SMhqwAh6EgD83AoAfHD0snAA1IoZjHAAPnnKArFwAFyJ8ilp1JnZPGz8TKrqoBkZXPXsQgVFAroAvkA&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=true&amp;presets=es2015%2Ctypescript&amp;prettier=true&amp;targets=&amp;version=7.8.3&amp;externalPlugins=" rel="nofollow">REPL</a></li>
<li>Minimal reproduction: <a href="https://babeljs.io/en/repl#?browsers=&amp;build=&amp;builtIns=false&amp;spec=false&amp;loose=true&amp;code_lz=AwAg_CBuILwHwgBQGcCuBbEBqGUCUIAXFLAsANxA&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=true&amp;presets=es2015%2Ctypescript&amp;prettier=true&amp;targets=&amp;version=7.8.3&amp;externalPlugins=" rel="nofollow">REPL</a></li>
</ul>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="0 ? v =&gt; (sum += v) : v =&gt; 0;"><pre class="notranslate"><span class="pl-c1">0</span> ? <span class="pl-s1">v</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">(</span><span class="pl-s1">sum</span> <span class="pl-c1">+=</span> <span class="pl-s1">v</span><span class="pl-kos">)</span> : <span class="pl-s1">v</span> <span class="pl-c1">=&gt;</span> <span class="pl-c1">0</span><span class="pl-kos">;</span></pre></div>
<blockquote>
<p dir="auto">/repl.ts: Only '=' operator can be used for specifying default value. (1:13)</p>
<blockquote>
<p dir="auto">1 | 0 ? v =&gt; (sum += v) : v =&gt; 0;</p>
</blockquote>
</blockquote>
<p dir="auto"><strong>Expected behavior/code</strong><br>
Babel should compile the above code with <code class="notranslate">typescript</code> enabled.</p>
<p dir="auto">I use rollup to bundle my app (contains many <code class="notranslate">async</code> functions) to work on IE11 or Safari 10. Here is my babel plugin setting in rollup.config:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="plugins: [
...
resolve(),
commonjs(),
    babel({
      &quot;babelrc&quot;: false,
      &quot;runtimeHelpers&quot;: true,
      exclude: 'node_modules/**',
      &quot;plugins&quot;: [
        &quot;@babel/plugin-external-helpers&quot;,
        &quot;@babel/plugin-transform-runtime&quot;
      ],
      &quot;presets&quot;: [
        ['@babel/preset-env', {
          modules: false,
          targets: {
            ie: 11,
            browsers: 'last 5 versions'
          },
          useBuiltIns: 'usage',
          debug: true,
        }]
      ]
    }),
   ...
]"><pre class="notranslate"><code class="notranslate">plugins: [
...
resolve(),
commonjs(),
    babel({
      "babelrc": false,
      "runtimeHelpers": true,
      exclude: 'node_modules/**',
      "plugins": [
        "@babel/plugin-external-helpers",
        "@babel/plugin-transform-runtime"
      ],
      "presets": [
        ['@babel/preset-env', {
          modules: false,
          targets: {
            ie: 11,
            browsers: 'last 5 versions'
          },
          useBuiltIns: 'usage',
          debug: true,
        }]
      ]
    }),
   ...
]
</code></pre></div>
<p dir="auto">Since <code class="notranslate">debug</code> is enabled, I can see the console output has:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Using targets:
{
  &quot;android&quot;: &quot;4.1&quot;,
  &quot;chrome&quot;: &quot;67&quot;,
  &quot;edge&quot;: &quot;14&quot;,
  &quot;firefox&quot;: &quot;60&quot;,
  &quot;ie&quot;: &quot;11&quot;,
  &quot;ios&quot;: &quot;10&quot;,
  &quot;opera&quot;: &quot;53&quot;,
  &quot;safari&quot;: &quot;10&quot;
}

Using modules transform: false

Using plugins:
  transform-template-literals { &quot;android&quot;:&quot;4.1&quot;, &quot;ie&quot;:&quot;11&quot; }
  transform-literals { &quot;android&quot;:&quot;4.1&quot;, &quot;ie&quot;:&quot;11&quot; }
  transform-function-name { &quot;android&quot;:&quot;4.1&quot;, &quot;edge&quot;:&quot;14&quot;, &quot;ie&quot;:&quot;11&quot; }
  transform-arrow-functions { &quot;android&quot;:&quot;4.1&quot;, &quot;ie&quot;:&quot;11&quot; }
  transform-block-scoped-functions { &quot;android&quot;:&quot;4.1&quot; }
  transform-classes { &quot;android&quot;:&quot;4.1&quot;, &quot;ie&quot;:&quot;11&quot; }
  transform-object-super { &quot;android&quot;:&quot;4.1&quot;, &quot;ie&quot;:&quot;11&quot; }
  transform-shorthand-properties { &quot;android&quot;:&quot;4.1&quot;, &quot;ie&quot;:&quot;11&quot; }
  transform-duplicate-keys { &quot;android&quot;:&quot;4.1&quot;, &quot;ie&quot;:&quot;11&quot; }
  transform-computed-properties { &quot;android&quot;:&quot;4.1&quot;, &quot;ie&quot;:&quot;11&quot; }
  transform-for-of { &quot;android&quot;:&quot;4.1&quot;, &quot;edge&quot;:&quot;14&quot;, &quot;ie&quot;:&quot;11&quot; }
  transform-sticky-regex { &quot;android&quot;:&quot;4.1&quot;, &quot;ie&quot;:&quot;11&quot; }
  transform-dotall-regex { &quot;android&quot;:&quot;4.1&quot;, &quot;edge&quot;:&quot;14&quot;, &quot;firefox&quot;:&quot;60&quot;, &quot;ie&quot;:&quot;11&quot;, &quot;ios&quot;:&quot;10&quot;, &quot;safari&quot;:&quot;10&quot; }
  transform-unicode-regex { &quot;android&quot;:&quot;4.1&quot;, &quot;ie&quot;:&quot;11&quot;, &quot;ios&quot;:&quot;10&quot;, &quot;safari&quot;:&quot;10&quot; }
  transform-spread { &quot;android&quot;:&quot;4.1&quot;, &quot;ie&quot;:&quot;11&quot; }
  transform-parameters { &quot;android&quot;:&quot;4.1&quot;, &quot;edge&quot;:&quot;14&quot;, &quot;ie&quot;:&quot;11&quot; }
  transform-destructuring { &quot;android&quot;:&quot;4.1&quot;, &quot;edge&quot;:&quot;14&quot;, &quot;ie&quot;:&quot;11&quot; }
  transform-block-scoping { &quot;android&quot;:&quot;4.1&quot;, &quot;ie&quot;:&quot;11&quot;, &quot;ios&quot;:&quot;10&quot;, &quot;safari&quot;:&quot;10&quot; }
  transform-typeof-symbol { &quot;android&quot;:&quot;4.1&quot;, &quot;ie&quot;:&quot;11&quot; }
  transform-new-target { &quot;android&quot;:&quot;4.1&quot;, &quot;ie&quot;:&quot;11&quot; }
  transform-regenerator { &quot;android&quot;:&quot;4.1&quot;, &quot;ie&quot;:&quot;11&quot; }
  transform-exponentiation-operator { &quot;android&quot;:&quot;4.1&quot;, &quot;ie&quot;:&quot;11&quot;, &quot;ios&quot;:&quot;10&quot;, &quot;safari&quot;:&quot;10&quot; }
  transform-async-to-generator { &quot;android&quot;:&quot;4.1&quot;, &quot;edge&quot;:&quot;14&quot;, &quot;ie&quot;:&quot;11&quot;, &quot;ios&quot;:&quot;10&quot;, &quot;safari&quot;:&quot;10&quot; }
  proposal-async-generator-functions { &quot;android&quot;:&quot;4.1&quot;, &quot;edge&quot;:&quot;14&quot;, &quot;ie&quot;:&quot;11&quot;, &quot;ios&quot;:&quot;10&quot;, &quot;safari&quot;:&quot;10&quot; }
  proposal-object-rest-spread { &quot;android&quot;:&quot;4.1&quot;, &quot;edge&quot;:&quot;14&quot;, &quot;ie&quot;:&quot;11&quot;, &quot;ios&quot;:&quot;10&quot;, &quot;safari&quot;:&quot;10&quot; }
  proposal-unicode-property-regex { &quot;android&quot;:&quot;4.1&quot;, &quot;edge&quot;:&quot;14&quot;, &quot;firefox&quot;:&quot;60&quot;, &quot;ie&quot;:&quot;11&quot;, &quot;ios&quot;:&quot;10&quot;, &quot;safari&quot;:&quot;10&quot; }
  proposal-json-strings { &quot;android&quot;:&quot;4.1&quot;, &quot;chrome&quot;:&quot;67&quot;, &quot;edge&quot;:&quot;14&quot;, &quot;firefox&quot;:&quot;60&quot;, &quot;ie&quot;:&quot;11&quot;, &quot;ios&quot;:&quot;10&quot;, &quot;opera&quot;:&quot;53&quot;, &quot;safari&quot;:&quot;10&quot; }
  proposal-optional-catch-binding { &quot;android&quot;:&quot;4.1&quot;, &quot;edge&quot;:&quot;14&quot;, &quot;ie&quot;:&quot;11&quot;, &quot;ios&quot;:&quot;10&quot;, &quot;safari&quot;:&quot;10&quot; }
...
[/Users/rbx0999/project/scilab/src/api/fetch.js] Added following polyfills:
  es6.object.keys { &quot;android&quot;:&quot;4.1&quot;, &quot;ie&quot;:&quot;11&quot; }
  es6.array.iterator { &quot;android&quot;:&quot;4.1&quot;, &quot;ie&quot;:&quot;11&quot; }
  web.dom.iterable { &quot;android&quot;:&quot;4.1&quot;, &quot;chrome&quot;:&quot;67&quot;, &quot;edge&quot;:&quot;14&quot;, &quot;firefox&quot;:&quot;60&quot;, &quot;ie&quot;:&quot;11&quot;, &quot;ios&quot;:&quot;10&quot;, &quot;opera&quot;:&quot;53&quot;, &quot;safari&quot;:&quot;10&quot; }
  regenerator-runtime { &quot;android&quot;:&quot;4.1&quot;, &quot;chrome&quot;:&quot;67&quot;, &quot;edge&quot;:&quot;14&quot;, &quot;firefox&quot;:&quot;60&quot;, &quot;ie&quot;:&quot;11&quot;, &quot;ios&quot;:&quot;10&quot;, &quot;opera&quot;:&quot;53&quot;, &quot;safari&quot;:&quot;10&quot; }
..."><pre class="notranslate"><code class="notranslate">Using targets:
{
  "android": "4.1",
  "chrome": "67",
  "edge": "14",
  "firefox": "60",
  "ie": "11",
  "ios": "10",
  "opera": "53",
  "safari": "10"
}

Using modules transform: false

Using plugins:
  transform-template-literals { "android":"4.1", "ie":"11" }
  transform-literals { "android":"4.1", "ie":"11" }
  transform-function-name { "android":"4.1", "edge":"14", "ie":"11" }
  transform-arrow-functions { "android":"4.1", "ie":"11" }
  transform-block-scoped-functions { "android":"4.1" }
  transform-classes { "android":"4.1", "ie":"11" }
  transform-object-super { "android":"4.1", "ie":"11" }
  transform-shorthand-properties { "android":"4.1", "ie":"11" }
  transform-duplicate-keys { "android":"4.1", "ie":"11" }
  transform-computed-properties { "android":"4.1", "ie":"11" }
  transform-for-of { "android":"4.1", "edge":"14", "ie":"11" }
  transform-sticky-regex { "android":"4.1", "ie":"11" }
  transform-dotall-regex { "android":"4.1", "edge":"14", "firefox":"60", "ie":"11", "ios":"10", "safari":"10" }
  transform-unicode-regex { "android":"4.1", "ie":"11", "ios":"10", "safari":"10" }
  transform-spread { "android":"4.1", "ie":"11" }
  transform-parameters { "android":"4.1", "edge":"14", "ie":"11" }
  transform-destructuring { "android":"4.1", "edge":"14", "ie":"11" }
  transform-block-scoping { "android":"4.1", "ie":"11", "ios":"10", "safari":"10" }
  transform-typeof-symbol { "android":"4.1", "ie":"11" }
  transform-new-target { "android":"4.1", "ie":"11" }
  transform-regenerator { "android":"4.1", "ie":"11" }
  transform-exponentiation-operator { "android":"4.1", "ie":"11", "ios":"10", "safari":"10" }
  transform-async-to-generator { "android":"4.1", "edge":"14", "ie":"11", "ios":"10", "safari":"10" }
  proposal-async-generator-functions { "android":"4.1", "edge":"14", "ie":"11", "ios":"10", "safari":"10" }
  proposal-object-rest-spread { "android":"4.1", "edge":"14", "ie":"11", "ios":"10", "safari":"10" }
  proposal-unicode-property-regex { "android":"4.1", "edge":"14", "firefox":"60", "ie":"11", "ios":"10", "safari":"10" }
  proposal-json-strings { "android":"4.1", "chrome":"67", "edge":"14", "firefox":"60", "ie":"11", "ios":"10", "opera":"53", "safari":"10" }
  proposal-optional-catch-binding { "android":"4.1", "edge":"14", "ie":"11", "ios":"10", "safari":"10" }
...
[/Users/rbx0999/project/scilab/src/api/fetch.js] Added following polyfills:
  es6.object.keys { "android":"4.1", "ie":"11" }
  es6.array.iterator { "android":"4.1", "ie":"11" }
  web.dom.iterable { "android":"4.1", "chrome":"67", "edge":"14", "firefox":"60", "ie":"11", "ios":"10", "opera":"53", "safari":"10" }
  regenerator-runtime { "android":"4.1", "chrome":"67", "edge":"14", "firefox":"60", "ie":"11", "ios":"10", "opera":"53", "safari":"10" }
...
</code></pre></div>
<p dir="auto">However, <code class="notranslate">async function</code> is still there in the final bundle.js.</p>
<p dir="auto">Here is the devDependencies part of my package.json:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="    &quot;@babel/core&quot;: &quot;^7.2.2&quot;,
    &quot;@babel/plugin-external-helpers&quot;: &quot;^7.2.0&quot;,
    &quot;@babel/plugin-transform-runtime&quot;: &quot;^7.1.0&quot;,
    &quot;@babel/preset-env&quot;: &quot;^7.2.3&quot;,
    &quot;rollup&quot;: &quot;^0.66.2&quot;,
    &quot;rollup-plugin-babel&quot;: &quot;^4.2.0&quot;,
    &quot;rollup-plugin-commonjs&quot;: &quot;^9.1.8&quot;,
    &quot;rollup-plugin-node-resolve&quot;: &quot;^3.4.0&quot;,
    ..."><pre class="notranslate"><code class="notranslate">    "@babel/core": "^7.2.2",
    "@babel/plugin-external-helpers": "^7.2.0",
    "@babel/plugin-transform-runtime": "^7.1.0",
    "@babel/preset-env": "^7.2.3",
    "rollup": "^0.66.2",
    "rollup-plugin-babel": "^4.2.0",
    "rollup-plugin-commonjs": "^9.1.8",
    "rollup-plugin-node-resolve": "^3.4.0",
    ...
</code></pre></div>