escodegen icon indicating copy to clipboard operation
escodegen copied to clipboard

Destructuring issue

Open chriscoyier opened this issue 8 years ago • 1 comments

const {a=1, b=2} = {a:2};

To esprima (link) returns the correct AST.

Back to JS through escodegen:

const {a, b} = { a: 2 };

Which leaves b undefined.

Seems like a bug?

chriscoyier avatar Dec 16 '16 17:12 chriscoyier

Ooops I didn't mean to close this. Seems to still be an issue.

Another possibly-related issue is related to template literals.

Code like this:

function returnHTML() {
  return `
    <h1>Hello</h1>
  `;
}

convereted to AST by esprima and back to JavaScript by escodegen, turns into:

function returnHTML() {
    return;
    `
    <h1>Hello</h1>
  `;
}

... which I don't think is right.

chriscoyier avatar Jan 26 '17 21:01 chriscoyier