lukehoban/es6features

SyntaxError: Unexpected token ...

gmonking opened this issue · 4 comments

var first = 1;
var last = 2;

var obj = {
    first,
    last
}

var newObj = {
    ...obj
}

Yes - that is not legal code.

Was there something in the overview that made you believe this should be legal?

redux has the return:

export default function applyMiddleware(...middlewares) {
  return (next) => (reducer, initialState) => {
    var store = next(reducer, initialState)
    var dispatch = store.dispatch
    var chain = []

    var middlewareAPI = {
      getState: store.getState,
      dispatch: (action) => dispatch(action)
    }
    chain = middlewares.map(middleware => middleware(middlewareAPI))
    dispatch = compose(...chain)(store.dispatch)

    return {
      ...store,
      dispatch
    }
  }
}

That code sample uses object literal spread operator, which is not part of ES6, but is a proposal for a future version of ecmascript. See https://github.com/sebmarkbage/ecmascript-rest-spread/blob/master/README.md.

It looks like Redux uses Babel in a mode that includes that feature.

OK. Thanks man

发自我的 iPhone

在 2016年1月2日,01:43,Luke Hoban notifications@github.com 写道:

That code sample uses object literal spread operator, which is not part of ES6, but is a proposal for a future version of ecmascript. See https://github.com/sebmarkbage/ecmascript-rest-spread/blob/master/README.md.

It looks like Redux uses Babel in a mode that includes that feature.


Reply to this email directly or view it on GitHub.