google / google/closure-compiler

Class statics: Arrow functions not supported in goog.defineClass.

Open
#1,204 6 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

The class was defined as followed:

``` javascript
var Test = goog.defineClass(null, {
constructor: function(){},

statics: {
test: () => console.log('This is a test')
}
});
```

http://closure-compiler-debugger.appspot.com/#input0%3Dvar%2520Test%2520%253D%2520goog.defineClass(null%252C%2520%257B%250A%2520%2520constructor%253A%2520function()%257B%257D%252C%250A%250A%2520%2520statics%253A%2520%257B%250A%2520%2520%2520%2520test%253A%2520()%2520%253D%253E%2520console.log('This%2520is%2520a%2520test')%250A%2520%2520%257D%250A%257D)%253B%250A%250ATest.test()%253B%26input1%26conformanceConfig%26externs%26refasterjs-template%26includeDefaultExterns%3D1%26CHECK_TYPES_NEW_INFERENCE%3D1%26CLOSURE_PASS%3D1%26LANG_IN_IS_ES6%3D1%26MISSING_PROPERTIES%3D1%26TRANSPILE%3D1
When compile, it throws a compiling error stating that arrow functions are not supported in goog.defineClass.

Previous version of compiler worked well with static arrow functions.

Please explain or fix it. Thanks!

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.