Skip to content

typescript preset: incompatible with += operator inside arrow functions, nested in ternary #11038

@buschtoens

Description

@buschtoens

Bug Report

  • I would like to work on a fix!
    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.

Current Behavior
The typescript preset is incompatible with d3-array/cumsum.js. The issue seems to only occur for arrow functions using the += operator, nested inside a ternary. When typescript is disabled, the code compiled without any issues.

Input Code

  • Original broken d3-array/cumsum.js: REPL
  • Minimal reproduction: REPL
0 ? v => (sum += v) : v => 0;

/repl.ts: Only '=' operator can be used for specifying default value. (1:13)

1 | 0 ? v => (sum += v) : v => 0;

Expected behavior/code
Babel should compile the above code with typescript enabled.

Metadata

Metadata

Labels

outdatedA closed issue/PR that is archived due to age. Recommended to make a new issuepkg: parser

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions