infer class name for classes that have static properties (#3589)
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
"babel-plugin"
|
||||
],
|
||||
"dependencies": {
|
||||
"babel-helper-function-name": "^6.8.0",
|
||||
"babel-plugin-syntax-class-properties": "^6.8.0",
|
||||
"babel-runtime": "^6.9.1"
|
||||
},
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/* eslint max-len: 0 */
|
||||
// todo: define instead of assign
|
||||
import nameFunction from "babel-helper-function-name";
|
||||
|
||||
export default function ({ types: t }) {
|
||||
let findBareSupers = {
|
||||
@@ -43,6 +44,7 @@ export default function ({ types: t }) {
|
||||
let ref;
|
||||
|
||||
if (path.isClassExpression() || !path.node.id) {
|
||||
nameFunction(path);
|
||||
ref = path.scope.generateUidIdentifier("class");
|
||||
} else { // path.isClassDeclaration() && path.node.id
|
||||
ref = path.node.id;
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
var Foo = class {
|
||||
static num = 0;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
var Foo = class {
|
||||
static num = 0;
|
||||
}
|
||||
|
||||
assert.equal(Foo.num, 0);
|
||||
assert.equal(Foo.num = 1, 1);
|
||||
assert.equal(Foo.name, "Foo");
|
||||
@@ -0,0 +1,5 @@
|
||||
var _class, _temp;
|
||||
|
||||
var Foo = (_temp = _class = function Foo() {
|
||||
babelHelpers.classCallCheck(this, Foo);
|
||||
}, _class.num = 0, _temp);
|
||||
Reference in New Issue
Block a user