Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
buschtoens opened this issue Jan 21, 2020 · 2 comments
Labels

Comments

@buschtoens
Copy link
Contributor

@buschtoens buschtoens commented Jan 21, 2020

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.

@babel-bot

This comment has been minimized.

Copy link
Collaborator

@babel-bot babel-bot commented Jan 21, 2020

Hey @buschtoens! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite."

@jridgewell

This comment has been minimized.

Copy link
Member

@jridgewell jridgewell commented Jan 21, 2020

To help you narrow it down, it's an issue with the parser and likely something in packages/babel-parser/src/plugins/typescript/index.js.

@jridgewell jridgewell added the claimed label Jan 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.