Skip to content

Esprima fails to parse classes that have public fields #2109

@jpstotz

Description

@jpstotz

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions