Reputation: 2073
I'm running into a problem transpiling the following code (redux reducer) with babel and the ES2015 preset. I'm (wrongly) assuming this is code that can be transpiled.
const todos = (state = [], action) => {
switch (action.type) {
case 'TOGGLE_TODO':
return state.map(todo =>
(todo.id === action.id)
? {
...todo,
completed: !todo.completed
}
: todo
)
default:
return state
}
}
export default todos
The error message
repl: Unexpected token (7:16)
5 | (todo.id === action.id)
6 | ? {
> 7 | ...todo,
Transpiling with the Stage0 preset works fine. I did verify this behaivor with the Babel online.
Upvotes: 0
Views: 72
Reputation: 5056
Because preset-2016
doesn't support object rest spread. It's stage 3 now
Upvotes: 1