Skip to content
This repository was archived by the owner on Apr 16, 2026. It is now read-only.
This repository was archived by the owner on Apr 16, 2026. It is now read-only.

Syntax highlighting not working for private fields #6249

Closed

Description

@TimvdLippe

Private fields (https://v8.dev/features/class-fields) use a # at the start of the field declaration in a class. CodeMirror currently doesn't highlight these private fields as fields and its syntax highlighting marks the whole line as red. Example

class Project {
  #id;
  
  constructor(name) {
    this.name = name;
    this.#id = Math.random();
  }
  
  get id() {
      return this.#id;
  }

  #setId(id) {
      this.#id = id;
  }

  aMethod() {}

  static fromStore(id, name) {
      const proj = new Project(name);
      proj.#setId(id);
      proj.aMethod();
      return proj; 
  }
}

Current syntax highlighting:

Screenshot 2020-04-27 at 11 01 05

(Code was pasted on https://codemirror.net/mode/javascript/index.html)

The expected syntax highlighting here is that private fields have the same color as normal fields (e.g. name in this example).

Downstream issue: https://bugs.chromium.org/p/chromium/issues/detail?id=1073903

Activity

  1. TimvdLippe commented on Apr 28, 2020

    @TimvdLippe
    ContributorAuthor

    Thanks for fixing this so quickly!

  2. added a commit that references this issue on Oct 31, 2020
  3. added a commit that references this issue on Sep 5, 2024
    a67ed9a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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