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

Code not compatible with babel #179

Closed
IlyaSemenov opened this issue Oct 30, 2020 · 2 comments
Closed

Code not compatible with babel #179

IlyaSemenov opened this issue Oct 30, 2020 · 2 comments

Comments

@IlyaSemenov
Copy link

FYI, latest babel wouldn't compile this code:

export default function cumsum(values, valueof) {
var sum = 0, index = 0;
return Float64Array.from(values, valueof === undefined
? v => (sum += +v || 0)
: v => (sum += +valueof(v, index++, values) || 0));
}

with this error:

ERROR in ./node_modules/d3-array/src/cumsum.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: /xxx/node_modules/d3-array/src/cumsum.js: Only '=' operator can be used for specifying default value. (4:15)

  2 |   var sum = 0, index = 0;
  3 |   return Float64Array.from(values, valueof === undefined
> 4 |     ? v => (sum += +v || 0)
    |                ^
  5 |     : v => (sum += +valueof(v, index++, values) || 0));
  6 | }

It's probably babel's issue, but I thought it was worth reporting it here, as may be it is an issue with d3-array.

@IlyaSemenov
Copy link
Author

My bad! Apparently a duplicate of #147. Also see babel/babel#11038

@derwaldgeist
Copy link

Just ran into the same error. #147 has been closed, but without any resolution. Upgrading Babel or downgrading d3-array is not an option for me, as I am using Meteor (which fixed Babel to a certain version) and react-globe that relies on d3-array@2.12.2 and I wouldn't want to break it.

I would appreciate if the code could be rewritten without the assignment in the ternary operator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants