ajmajmajma
ajmajmajma

Reputation: 14216

javascript, unrecognized character with spread operator inside reduce

I am building a little function and seem to be having an issue with the spread operator. My linter is yelling at me about a spread operator, but I have no issue with using it elsewhere in my app. I have been starting at this and cannot for the life of me figure out why. Here is the function :

function mapDispatchToProps(dispatch, props) {
return actionCreators.reduce(function(memo, value, key) {
    return {...memo,
        [key]: value.bind(null, dispatch)
    };
}, {});
}

it's pointing to the second . in the spread operator and saying unrecognized character. I believe I have something syntactically incorrect but can't seem to figure it out. Any help would be much appreciated, thanks!

Upvotes: 2

Views: 118

Answers (1)

Felix Kling
Felix Kling

Reputation: 816790

Spread properties are not part of ES6. It is a proposal for ES20XX. Your linter probably doesn't know of this proposal yet.

You need to configure your linter to use a parser that understands this syntax or use a different linter that allows you to do that, such as http://eslint.org/ .

Upvotes: 1

Related Questions