Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/transformers/runtimesyntax.go
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ func (tx *RuntimeSyntaxTransformer) visitConstructorBody(body *ast.Block, constr
}

var superPath []int
if ast.IsClassLike(grandparentOfBody) && ast.GetExtendsHeritageClauseElement(grandparentOfBody) != nil {
if ast.IsClassLike(grandparentOfConstructor) && ast.GetExtendsHeritageClauseElement(grandparentOfConstructor) != nil {
superPath = findSuperStatementIndexPath(rest, 0)
}

Expand Down
9 changes: 9 additions & 0 deletions internal/transformers/runtimesyntax_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,15 @@ func TestParameterPropertyTransformer(t *testing.T) {
constructor(x) {
this.x = x;
}
}`},
{title: "parameter properties with super call", input: `class B {} class C extends B { constructor(public x) { super(); } }`, output: `class B {
}
class C extends B {
x;
constructor(x) {
super();
this.x = x;
}
}`},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class Point {
class ColoredPoint extends Point {
color;
constructor(x, y, color) {
this.color = color;
super(x, y);
this.color = color;
}
toString() {
return super.toString() + " color=" + this.color;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
+class ColoredPoint extends Point {
+ color;
+ constructor(x, y, color) {
+ this.color = color;
+ super(x, y);
+ this.color = color;
+ }
+ toString() {
+ return super.toString() + " color=" + this.color;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class Point {
class Point3D extends Point {
z;
constructor(x, y, z, m) {
this.z = z;
super(x, y);
this.z = z;
}
getDist() {
return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.m);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
+class Point3D extends Point {
+ z;
+ constructor(x, y, z, m) {
+ this.z = z;
+ super(x, y);
+ this.z = z;
+ }
+ getDist() {
return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.m);
Expand Down
6 changes: 3 additions & 3 deletions testdata/baselines/reference/submodule/compiler/baseCheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,22 @@ class ELocVar extends C {
class D extends C {
z;
constructor(z) {
this.z = z;
super(this.z);
this.z = z;
}
} // too few params
class E extends C {
z;
constructor(z) {
this.z = z;
super(0, this.z);
this.z = z;
}
}
class F extends C {
z;
constructor(z) {
this.z = z;
super("hello", this.z);
this.z = z;
}
} // first param type
function f() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@
+class D extends C {
+ z;
+ constructor(z) {
+ this.z = z;
+ super(this.z);
+ this.z = z;
}
- return E;
-}(C));
Expand All @@ -86,17 +86,17 @@
+class E extends C {
+ z;
+ constructor(z) {
+ this.z = z;
+ super(0, this.z);
+ this.z = z;
}
- return F;
-}(C)); // first param type
+}
+class F extends C {
+ z;
+ constructor(z) {
+ this.z = z;
+ super("hello", this.z);
+ this.z = z;
+ }
+} // first param type
function f() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class A {
class B extends A {
data;
constructor(x, data) {
this.data = data;
super(x);
this.data = data;
}
}
class C extends A {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
+class B extends A {
+ data;
+ constructor(x, data) {
+ this.data = data;
+ super(x);
+ this.data = data;
}
- return B;
-}(A));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,31 +162,31 @@ class I extends Object {
class J extends G {
p1;
constructor(p1) {
this.p1 = p1;
super(); // NO ERROR
this.p1 = p1;
}
}
class K extends G {
p1;
constructor(p1) {
this.p1 = p1;
var i = 0;
super();
this.p1 = p1;
}
}
class L extends G {
p1;
constructor(p1) {
this.p1 = p1;
super(); // NO ERROR
this.p1 = p1;
}
}
class M extends G {
p1;
constructor(p1) {
this.p1 = p1;
var i = 0;
super();
this.p1 = p1;
}
}
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@
+class J extends G {
+ p1;
+ constructor(p1) {
+ this.p1 = p1;
+ super(); // NO ERROR
+ this.p1 = p1;
}
- return D;
-}());
Expand Down Expand Up @@ -149,12 +149,12 @@
+class K extends G {
+ p1;
+ constructor(p1) {
+ this.p1 = p1;
var i = 0;
- _this = _super.call(this) || this;
- _this.p1 = p1;
- return _this;
+ super();
+ this.p1 = p1;
}
- return K;
-}(G));
Expand All @@ -168,8 +168,8 @@
+class L extends G {
+ p1;
+ constructor(p1) {
+ this.p1 = p1;
+ super(); // NO ERROR
+ this.p1 = p1;
}
- return L;
-}(G));
Expand All @@ -181,12 +181,12 @@
+class M extends G {
+ p1;
+ constructor(p1) {
+ this.p1 = p1;
var i = 0;
- _this = _super.call(this) || this;
- _this.p1 = p1;
- return _this;
+ super();
+ this.p1 = p1;
}
- return M;
-}(G));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ class b1 extends a {
class b2 extends a {
_super;
constructor(_super) {
this._super = _super;
super();
this._super = _super;
}
}
class b3 extends a {
Expand All @@ -55,7 +55,7 @@ class b3 extends a {
class b4 extends a {
_super;
constructor(_super) {
this._super = _super;
super();
this._super = _super;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
+class b2 extends a {
+ _super;
+ constructor(_super) {
+ this._super = _super;
+ super();
+ this._super = _super;
}
- return b1;
-}(a));
Expand All @@ -63,8 +63,8 @@
+class b4 extends a {
+ _super;
+ constructor(_super) {
+ this._super = _super;
+ super();
+ this._super = _super;
}
- return b3;
-}(a));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Super {
class Sub extends Super {
options;
constructor(options) {
this.options = options;
super(options.value);
this.options = options;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
+class Sub extends Super {
+ options;
+ constructor(options) {
+ this.options = options;
+ super(options.value);
+ this.options = options;
}
- return Sub;
-}(Super));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class B extends A {
'someStringForEgngInject';
"use strict";
'someStringForEgngInject';
this.x = x;
super();
this.x = x;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
- return _this;
+ "use strict";
+ 'someStringForEgngInject';
+ this.x = x;
+ super();
+ this.x = x;
}
- return B;
-}(A));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class B extends A {
'someStringForEgngInject';
"use strict";
'someStringForEgngInject';
this.x = x;
super();
this.x = x;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
constructor(x) {
"use strict";
'someStringForEgngInject';
- super();
+ "use strict";
+ 'someStringForEgngInject';
super();
this.x = x;
+ super();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class B extends A {
'someStringForEgngInject';
"use strict";
'someStringForEgngInject';
this.x = x;
super();
this.x = x;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
- return _this;
+ "use strict";
+ 'someStringForEgngInject';
+ this.x = x;
+ super();
+ this.x = x;
}
- return B;
-}(A));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class B extends A {
'someStringForEgngInject';
"use strict";
'someStringForEgngInject';
this.x = x;
super();
this.x = x;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
constructor(x) {
"use strict";
'someStringForEgngInject';
- super();
+ "use strict";
+ 'someStringForEgngInject';
super();
this.x = x;
- this.blah = 2;
+ super();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ class Foo extends Bar {
boo(x) { return x; }
static statVal = 0;
constructor(x, y, z = 0) {
super(x);
this.y = y;
this.z = z;
super(x);
this.x = x;
this.gar = 5;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@
+ boo(x) { return x; }
+ static statVal = 0;
+ constructor(x, y, z = 0) {
+ super(x);
+ this.y = y;
+ this.z = z;
+ super(x);
+ this.x = x;
+ this.gar = 5;
}
Expand Down
Loading