question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unexpected token on object spread

See original GitHub issue

Apologies if this is for the wrong project since I haven’t been able to do a direct 6to5 transform on the command line but this works in the 6to5 REPL.

In test.js:

var props = {a: 1, b: 2, c: 3};
var {a, ...other} = props;

I get the error

test.js:2 var { a, …other } = props; ^ ParseError: Unexpected token

Using the command browserify .\test.js -t [6to5ify --experimental --playground --whitelist es7.objectSpread] --outfile bundle.js

I’ve tried various combinations of the experimental, playground, and whitelist settings but to no avail.

Am I missing something?

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:8

github_iconTop GitHub Comments

7reactions
worldsayshicommented, Jan 5, 2016

In case of useful, here’s a snippet from my build script:

...
var b = browserify({
  cache: {},
  packageCache: {},
  plugin: [watchify],
  entries: ["./js/index.js"],
  debug: true
}).transform("babelify", {
    presets: ["es2015", "react", "stage-2"]
  }).on('update', bundle)
    .on('log', log);
...
5reactions
worldsayshicommented, Jan 5, 2016

I think what @oguzbilgic was referring to is this: http://babeljs.io/docs/usage/options/

Adding stage-2 preset solved this problem for me. These links may be useful to others walking this path: https://babeljs.io/docs/plugins/ http://babeljs.io/docs/plugins/preset-stage-2/

Read more comments on GitHub >

github_iconTop Results From Across the Web

spread operator in react throwing error of Unexpected token
i had installed eslint before, so I deleted it and installed transform-object-rest-spread again. I followed all the methods given in the link ...
Read more >
Unexpected token ... ( spread operator ) #9675 - babel ...
Bug Report Babel can't recognize spread operator (..) return resolve(user && { ...user, domain }); i tried many solutions but without result ...
Read more >
Error Following React Tutorial spread operator is ...
Error Following React Tutorial spread operator is unexpected token ... OK, the component looks OK, assuming the rest of the file is fine....
Read more >
A few neat things you can do with the vanilla JS spread ...
The spread syntax operator (...) takes an array or object (or other iterable) and expands its items into their own individual values. let ......
Read more >
Babel 6->7: Error unknown: Unexpected token (spread operator)
[Solved]-Babel 6->7: Error unknown: Unexpected token (spread operator)-Vue.js · npm cache clean --force · inside your main repo folder: rm -rf node_modules/ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found