`typescript` preset: incompatible with `+=` operator inside arrow functions, nested in ternary
See original GitHub issueBug 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
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.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:25
- Comments:40 (17 by maintainers)
Top Results From Across the Web
[Resolved] Upgrading to 2.2.1 breaks module compilation - help
The issue seems to only occur for arrow functions using the `+=` operator, nested inside a ternary. When `typescript` is disabled, the code ......
Read more >javascript - Arrow Function Not Working In Ternary Operator
You have to execute the function you declared: (() => { holder.name.style.backgroundColor = holderbg holder.target.
Read more >Arrow function expressions - JavaScript - MDN Web Docs
Arrow functions cannot use yield within their body and cannot be created as generator functions. Try it.
Read more >Code Inspections in PHP | PhpStorm Documentation - JetBrains
Reports the parameters in function calls whose types are not compatible with the ones defined via Closure . Warning. PHPUnit ...
Read more >Python vs JavaScript for Pythonistas
Code Blocks; Statements; Identifiers; Comments; String Literals; Variable Scopes; Switch Statements; Enumerations; Arrow Functions; Default Arguments ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@pelly You need to check your
yarn.lock
and manually merge the duplicate elements that you’ve probably got afteryarn add d3-array@2.3.3
:A safer approach would be to add a static resolution to
package.json
:and re-run
yarn
.I had same problem. I’m wondering if ignoring cumsum.js could be a workaround.
Notes: