google / google/closure-compiler

Support use of `this` keyword in static ES6 methods

Open
#2,397 8 comments 20 reactions 0 assignees View on GitHub
ES6
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

It's very common (and safe) to use the `this` keyword in a static member definition:

```js
class Foo {
static get baz() { return 'baz'; }

static bar() {
console.log(this.baz);
}
}
```

We should replace the `this` keyword with a reference to the class name.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.