7

Getting this error, but unlike other posts I've found on stack overflow, it isn't due to the fact that the spread operator doesn't appear last. In fact, it occurs because of the trailing comma:

const SlashedPrice = ({
    price,
    currencySymbol,
    ...props,
}) => {

When I remove the comma from ...props, the error goes away. At first, I thought this was an issue with babel, but I've included 2 new rules with no luck: "@babel/plugin-proposal-object-rest-spread" and "syntax-trailing-function-commas",

At this point I am at a loss as to what is causing the issue. Where can I begin looking to debug?

Background: Everything in my codebase was working fine, until I removed node_modules and reran yarn install.

Tycholiz
  • 1,102
  • 4
  • 17
  • 33

1 Answers1

18

The problem is that, when you let the comma after the ...props, the props isn't the last item anymore. The ...props is the Rest that the error is talking about. It has nothing to do with babel.

Reference here

reisdev
  • 3,215
  • 2
  • 17
  • 38
  • 1
    but how come this was never an issue before? This is what I can't seem to understand. Before I'd always had `...props,`, and all of a sudden it's an issue – Tycholiz Oct 30 '19 at 18:59
  • 1
    @Tycholiz one of your packages may have updated it dependencies and this issue has come out! if you're using git to version control, take a look at your `package-lock.json` to see which packages has changed on the last commits – reisdev Oct 30 '19 at 19:22