Skip to content

[Bug]: JS Mode incorrectly flags static class properties as syntax error #5876

@Funaen

Description

@Funaen

Describe the bug

In the JavaScript (JS) mode of Ace Editor, declaring static class properties (fields) causes a syntax highlighting and error detection issue. The editor incorrectly flags the static property declaration as a syntax error, even though it is valid JavaScript syntax (part of ECMAScript 2022 / ES13).

Expected Behavior

The static class property declaration (static myStaticField = 'initial value';) should be recognized as valid syntax and should not be highlighted as an error.

Current Behavior

The line containing the static class property declaration is highlighted with an error marker, indicating a syntax error.

Reproduction Steps

  1. Open Ace Editor.
  2. Set the mode to ace/mode/javascript.
  3. Enter the following code snippet:
class Example {
  static myStaticField = 'initial value'; // --> Warning: Class properties must be methods. Expected '(' but instead saw '='.

  constructor() {
    console.log(Example.myStaticField);
  }
}

const instance = new Example();

Possible Solution

No response

Additional Information/Context

No response

Ace Version / Browser / OS / Keyboard layout

1.39.1 / any / any

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions