Esm: Destructuring parameters - defaults break code

Created on 21 Sep 2017  路  7Comments  路  Source: standard-things/esm

code like this is supported & executed in Node 8.3+ without problems:

module.exports = ({ foo, bar = 10 }) => {
  console.log(foo, bar);
}

However if I use ESM to rewrite it into ES module form:

export default ({ foo, bar = 10 }) => {
  console.log(foo, bar);
}

I get SyntaxError: Unexpected token (1:32). Removing default value for bar will solve problem, but now I lost default parameter value functionality.

bug

All 7 comments

Thanks @srigi!

It's a bug in our object rest/spread extension.

v0.11.0 is released :tada:

Thanks @jdalton, works like a charm.

Is there a unit test to make sure this didn't break again? It seems to have worked through 0.16.0, but is broken again in 0.17.0 馃槶

@jdalton great catch! I hadn't realized it was only an issue with multiple destructured arguments.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ericelliott picture ericelliott  路  3Comments

StphamZ picture StphamZ  路  3Comments

mbostock picture mbostock  路  3Comments

dnalborczyk picture dnalborczyk  路  3Comments

clock157 picture clock157  路  3Comments