Class Props: Don't rename constructor collisions with static props (#7813)

Static props aren't evaluated inside the constructor, so there can't be a collision.
This commit is contained in:
Justin Ridgewell 2018-04-25 23:45:52 -04:00 committed by GitHub
parent 47201db61e
commit 8c46fd159f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 1 deletions

View File

@ -199,7 +199,10 @@ export default declare((api, options) => {
}
const state = { scope: constructor.scope };
for (const prop of props) prop.traverse(referenceVisitor, state);
for (const prop of props) {
if (prop.node.static) continue;
prop.traverse(referenceVisitor, state);
}
//

View File

@ -2,8 +2,10 @@ var foo = "bar";
class Foo {
bar = foo;
static bar = baz;
constructor() {
var foo = "foo";
var baz = "baz";
}
}

View File

@ -6,4 +6,7 @@ var Foo = function Foo() {
babelHelpers.classCallCheck(this, Foo);
this.bar = foo;
var _foo = "foo";
var baz = "baz";
};
Foo.bar = baz;

View File

@ -2,8 +2,10 @@ var foo = "bar";
class Foo {
bar = foo;
static bar = baz;
constructor() {
var foo = "foo";
var baz = "baz";
}
}

View File

@ -6,4 +6,7 @@ var Foo = function Foo() {
babelHelpers.classCallCheck(this, Foo);
babelHelpers.defineProperty(this, "bar", foo);
var _foo = "foo";
var baz = "baz";
};
babelHelpers.defineProperty(Foo, "bar", baz);