standard-things / esm

Tomorrow's ECMAScript modules today!
Other
5.26k stars 146 forks source link

Failure when using class properties with calculated name. #787

Closed coreyfarrell closed 5 years ago

coreyfarrell commented 5 years ago
const kSymbol = Symbol();

class Foo {
    [kSymbol] = 1;
}

export default new Foo()[kSymbol];

The above fails when run under esm, the [kSymbol] = 1; throws a syntax error (under node.js 12). node.js 12 has no problem with this syntax, replacing export default with module.exports = makes this code work even with esm (I assume ESM detects lack of import/export and disables itself).

dnalborczyk commented 5 years ago

thank you @coreyfarrell! seems to be a parser issue.