Why do I get a syntax error when using a spread operator?

Viewed 2103

I'm using ES6's spread operator with Babel as a transpiler to ES5. When I use the spread operator like so:

const { height, weight, radius, ...otherValues } = sphere;

I get a SyntaxError:

ERROR in ./src/sphere.js
Module build failed: SyntaxError: Unexpected token (7:36)

   6 | 
>  7 |   const { height, weight, radius, ...otherValues } = sphere;
     |                                   ^
   8 | 

Why is this?

1 Answers
Related