jquery / esprima

ECMAScript parsing infrastructure for multipurpose analysis
http://esprima.org
BSD 2-Clause "Simplified" License
7.04k stars 786 forks source link

Esprima fails to parse classes that have public fields #2109

Open jpstotz opened 2 years ago

jpstotz commented 2 years ago

When trying to parse the example code from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes#public_field_declarations Esprima fails with Error: Line 3: Unexpected token =

var esprima = require('nightly-esprima'); // installed version 2021.8.30

var program = `
class Rectangle {
    height = 0;
    width;
    constructor(height, width) {
      this.height = height;
      this.width = width;
    }
}
`;

esprima.parseScript(program);

tested using Node.js v14.18.1

jpstotz commented 2 years ago

Looks like one of the waiting pull requests seem to already cover this case, because when I switch to esprima-next I don't get an error.

jogibear9988 commented 2 years ago

@jpstotz yes, I fixed this in my fork, cause there seems to be no move forward here...