Skip to content

Commit cbfa795

Browse files
committed
Properly handle classes inside constructor calls
1 parent a4a08c9 commit cbfa795

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

src/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,9 @@ export default function (babel) {
367367
function containsSuperCall(path) {
368368
let hasSuper = false;
369369
path.traverse({
370+
Class(classPath) {
371+
classPath.skip();
372+
},
370373
Super(superPath) {
371374
if (superPath.parentPath.isCallExpression()) {
372375
hasSuper = true;
@@ -428,6 +431,9 @@ export default function (babel) {
428431
// directly after each instance of super(), insert the thingies there.
429432
if (node.superClass) {
430433
constructorPath.traverse({
434+
Class(classPath) {
435+
classPath.skip();
436+
},
431437
Super(superPath) {
432438
if (!superPath.parentPath.isCallExpression()) return;
433439
let superStatementPath = superPath.getStatementParent();
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class A extends B {
2+
constructor() ->
3+
class C extends B:
4+
constructor() ->
5+
super()
6+
7+
f() => this
8+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class A extends B {
2+
constructor(..._args) {
3+
super(..._args);
4+
this.f = this.f.bind(this);
5+
6+
class C extends B {
7+
constructor() {
8+
super();
9+
}
10+
}
11+
}f() {
12+
return this;
13+
}
14+
}

0 commit comments

Comments
 (0)