Unexpected token `..` when using spread operator in function arguments
See original GitHub issueThe following code:
function mergeAndConcat(...objects) {
// stuff
}
Is throwing error Unexpected token ..
on line 3, which is the function definition. I’ve got the spread
option set to true
in the ecmaFeatures
section of my config, so I wouldn’t expect the above to cause an error.
Thanks in advance 😃
Jack
Issue Analytics
- State:
- Created 8 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Why is this spread operator causing a SyntaxError
Whenever I run a file containing this in Node.js or PHP I get a SyntaxError: Unexpected token, citing the spread operator [ ......
Read more >A few neat things you can do with the vanilla JS spread syntax ...
The spread operator can be really useful for some specific situations. Passing an array of arguments into a function as individual arguments #....
Read more >Spread arrow function spread argument Unexpected token ...
I have a problem, I've imported a new package in my project and it seems to be the first (for me) that uses...
Read more >Spread syntax (...) - JavaScript - MDN Web Docs - Mozilla
The spread (...) syntax allows an iterable, such as an array or string, to be expanded in places where zero or more arguments...
Read more >SyntaxError: Unexpected token - JavaScript
The JavaScript exceptions "unexpected token" occur when a specific language construct was expected, but something else was provided.
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 FreeTop 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
Top GitHub Comments
That’s not a
spread
operator, it’s arest
parameter. You need to enable therestParams
flag.Somehow
restParams
is missing in the documentation, but it is mentioned in the documentation of espree.I believe all concerns have been addressed here, so closing.