Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Esprima fails to parse classes that have public fields #2109

Open
jpstotz opened this issue Jan 27, 2022 · 2 comments
Open

Esprima fails to parse classes that have public fields #2109

jpstotz opened this issue Jan 27, 2022 · 2 comments

Comments

@jpstotz
Copy link

jpstotz commented Jan 27, 2022

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
Copy link
Author

jpstotz commented Jan 27, 2022

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants