google / google/closure-compiler

Cannot compile static properties for classes; static methods are fine

Open
#3,477 12 comments 8 reactions 0 assignees View on GitHub
internal-issue-created
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

```
class Test {
static myTest = "abc";
}
```
fails to compile.

I'm getting around this by doing

```
class Test {
static get myTest() { return "abc" };
}
```
and `@language_out ES5` flag to get some kind of output.

Sadly, static property inheritance seems to really trip up the compiler. Before I relied on static values in my classes, I was able to get it to compile and work on the advanced setting - might even consider reverting my changes just to get it to work 100% again.

Any recommendations also welcome.

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.