Skip to content

Commit 1b3dd6d

Browse files
author
Josh Goldberg
committed
Remove unused param and unnecessary baseline comments
1 parent 39d9901 commit 1b3dd6d

File tree

6 files changed

+34
-41
lines changed

6 files changed

+34
-41
lines changed

src/compiler/transformers/classFields.ts

+3-10
Original file line numberDiff line numberDiff line change
@@ -1371,11 +1371,9 @@ namespace ts {
13711371
*
13721372
* @param properties An array of property declarations to transform.
13731373
* @param receiver The receiver on which each property should be assigned.
1374-
* @param insertionIndex How far after a found property to splice the expression statement, if not the end of the array.
13751374
*/
1376-
function addPropertyOrClassStaticBlockStatements(statements: Statement[], properties: readonly (PropertyDeclaration | ClassStaticBlockDeclaration)[], receiver: LeftHandSideExpression, insertionIndex?: number) {
1377-
for (let i = 0; i < properties.length; i += 1) {
1378-
const property = properties[i];
1375+
function addPropertyOrClassStaticBlockStatements(statements: Statement[], properties: readonly (PropertyDeclaration | ClassStaticBlockDeclaration)[], receiver: LeftHandSideExpression) {
1376+
for (const property of properties) {
13791377
const expression = isClassStaticBlockDeclaration(property) ?
13801378
transformClassStaticBlockDeclaration(property) :
13811379
transformProperty(property, receiver);
@@ -1393,12 +1391,7 @@ namespace ts {
13931391
setSyntheticLeadingComments(expression, undefined);
13941392
setSyntheticTrailingComments(expression, undefined);
13951393

1396-
if (insertionIndex !== undefined) {
1397-
statements.splice(i + insertionIndex, 0, statement);
1398-
}
1399-
else {
1400-
statements.push(statement);
1401-
}
1394+
statements.push(statement);
14021395
}
14031396
}
14041397

tests/baselines/reference/derivedClassParameterProperties.errors.txt

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassP
1717
class Derived extends Base {
1818
constructor(y: string) {
1919
var a = 1;
20-
super(); // ok
20+
super();
2121
}
2222
}
2323

@@ -30,7 +30,7 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassP
3030

3131
class Derived3 extends Base {
3232
constructor(public y: string) {
33-
super(); // ok
33+
super();
3434
var a = 1;
3535
}
3636
}
@@ -46,7 +46,7 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassP
4646
class Derived5 extends Base {
4747
a = 1;
4848
constructor(y: string) {
49-
super(); // ok
49+
super();
5050
var b = 2;
5151
}
5252
}
@@ -58,7 +58,7 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassP
5858
~~~~
5959
!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
6060
var b = 2;
61-
super(); // error: "super" has to be called before "this" accessing
61+
super();
6262
}
6363
}
6464

@@ -86,7 +86,7 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassP
8686
a = 1;
8787
b: number;
8888
constructor(y: string) {
89-
super(); // ok
89+
super();
9090
this.a = 3;
9191
this.b = 3;
9292
}
@@ -119,7 +119,7 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassP
119119
a = 1;
120120
b: number;
121121
constructor(y: string) {
122-
super(); // ok
122+
super();
123123
this.a = 3;
124124
this.b = 3;
125125
}

tests/baselines/reference/derivedClassParameterProperties.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Base {
88
class Derived extends Base {
99
constructor(y: string) {
1010
var a = 1;
11-
super(); // ok
11+
super();
1212
}
1313
}
1414

@@ -21,7 +21,7 @@ class Derived2 extends Base {
2121

2222
class Derived3 extends Base {
2323
constructor(public y: string) {
24-
super(); // ok
24+
super();
2525
var a = 1;
2626
}
2727
}
@@ -37,7 +37,7 @@ class Derived4 extends Base {
3737
class Derived5 extends Base {
3838
a = 1;
3939
constructor(y: string) {
40-
super(); // ok
40+
super();
4141
var b = 2;
4242
}
4343
}
@@ -47,7 +47,7 @@ class Derived6 extends Base {
4747
constructor(y: string) {
4848
this.a = 1;
4949
var b = 2;
50-
super(); // error: "super" has to be called before "this" accessing
50+
super();
5151
}
5252
}
5353

@@ -65,7 +65,7 @@ class Derived8 extends Base {
6565
a = 1;
6666
b: number;
6767
constructor(y: string) {
68-
super(); // ok
68+
super();
6969
this.a = 3;
7070
this.b = 3;
7171
}
@@ -88,7 +88,7 @@ class Derived10<T> extends Base2<T> {
8888
a = 1;
8989
b: number;
9090
constructor(y: string) {
91-
super(); // ok
91+
super();
9292
this.a = 3;
9393
this.b = 3;
9494
}
@@ -172,7 +172,7 @@ var Derived6 = /** @class */ (function (_super) {
172172
var _this = this;
173173
_this.a = 1;
174174
var b = 2;
175-
_this = _super.call(this) || this; // error: "super" has to be called before "this" accessing
175+
_this = _super.call(this) || this;
176176
return _this;
177177
}
178178
return Derived6;

tests/baselines/reference/derivedClassParameterProperties.symbols

+6-6
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Derived extends Base {
1818
var a = 1;
1919
>a : Symbol(a, Decl(derivedClassParameterProperties.ts, 8, 11))
2020

21-
super(); // ok
21+
super();
2222
>super : Symbol(Base, Decl(derivedClassParameterProperties.ts, 0, 0))
2323
}
2424
}
@@ -45,7 +45,7 @@ class Derived3 extends Base {
4545
constructor(public y: string) {
4646
>y : Symbol(Derived3.y, Decl(derivedClassParameterProperties.ts, 21, 16))
4747

48-
super(); // ok
48+
super();
4949
>super : Symbol(Base, Decl(derivedClassParameterProperties.ts, 0, 0))
5050

5151
var a = 1;
@@ -81,7 +81,7 @@ class Derived5 extends Base {
8181
constructor(y: string) {
8282
>y : Symbol(y, Decl(derivedClassParameterProperties.ts, 37, 16))
8383

84-
super(); // ok
84+
super();
8585
>super : Symbol(Base, Decl(derivedClassParameterProperties.ts, 0, 0))
8686

8787
var b = 2;
@@ -107,7 +107,7 @@ class Derived6 extends Base {
107107
var b = 2;
108108
>b : Symbol(b, Decl(derivedClassParameterProperties.ts, 47, 11))
109109

110-
super(); // error: "super" has to be called before "this" accessing
110+
super();
111111
>super : Symbol(Base, Decl(derivedClassParameterProperties.ts, 0, 0))
112112
}
113113
}
@@ -153,7 +153,7 @@ class Derived8 extends Base {
153153
constructor(y: string) {
154154
>y : Symbol(y, Decl(derivedClassParameterProperties.ts, 65, 16))
155155

156-
super(); // ok
156+
super();
157157
>super : Symbol(Base, Decl(derivedClassParameterProperties.ts, 0, 0))
158158

159159
this.a = 3;
@@ -220,7 +220,7 @@ class Derived10<T> extends Base2<T> {
220220
constructor(y: string) {
221221
>y : Symbol(y, Decl(derivedClassParameterProperties.ts, 88, 16))
222222

223-
super(); // ok
223+
super();
224224
>super : Symbol(Base2, Decl(derivedClassParameterProperties.ts, 70, 1))
225225

226226
this.a = 3;

tests/baselines/reference/derivedClassParameterProperties.types

+6-6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Derived extends Base {
1919
>a : number
2020
>1 : 1
2121

22-
super(); // ok
22+
super();
2323
>super() : void
2424
>super : typeof Base
2525
}
@@ -49,7 +49,7 @@ class Derived3 extends Base {
4949
constructor(public y: string) {
5050
>y : string
5151

52-
super(); // ok
52+
super();
5353
>super() : void
5454
>super : typeof Base
5555

@@ -91,7 +91,7 @@ class Derived5 extends Base {
9191
constructor(y: string) {
9292
>y : string
9393

94-
super(); // ok
94+
super();
9595
>super() : void
9696
>super : typeof Base
9797

@@ -122,7 +122,7 @@ class Derived6 extends Base {
122122
>b : number
123123
>2 : 2
124124

125-
super(); // error: "super" has to be called before "this" accessing
125+
super();
126126
>super() : void
127127
>super : typeof Base
128128
}
@@ -176,7 +176,7 @@ class Derived8 extends Base {
176176
constructor(y: string) {
177177
>y : string
178178

179-
super(); // ok
179+
super();
180180
>super() : void
181181
>super : typeof Base
182182

@@ -249,7 +249,7 @@ class Derived10<T> extends Base2<T> {
249249
constructor(y: string) {
250250
>y : string
251251

252-
super(); // ok
252+
super();
253253
>super() : void
254254
>super : typeof Base2
255255

tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassParameterProperties.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Base {
77
class Derived extends Base {
88
constructor(y: string) {
99
var a = 1;
10-
super(); // ok
10+
super();
1111
}
1212
}
1313

@@ -20,7 +20,7 @@ class Derived2 extends Base {
2020

2121
class Derived3 extends Base {
2222
constructor(public y: string) {
23-
super(); // ok
23+
super();
2424
var a = 1;
2525
}
2626
}
@@ -36,7 +36,7 @@ class Derived4 extends Base {
3636
class Derived5 extends Base {
3737
a = 1;
3838
constructor(y: string) {
39-
super(); // ok
39+
super();
4040
var b = 2;
4141
}
4242
}
@@ -46,7 +46,7 @@ class Derived6 extends Base {
4646
constructor(y: string) {
4747
this.a = 1;
4848
var b = 2;
49-
super(); // error: "super" has to be called before "this" accessing
49+
super();
5050
}
5151
}
5252

@@ -64,7 +64,7 @@ class Derived8 extends Base {
6464
a = 1;
6565
b: number;
6666
constructor(y: string) {
67-
super(); // ok
67+
super();
6868
this.a = 3;
6969
this.b = 3;
7070
}
@@ -87,7 +87,7 @@ class Derived10<T> extends Base2<T> {
8787
a = 1;
8888
b: number;
8989
constructor(y: string) {
90-
super(); // ok
90+
super();
9191
this.a = 3;
9292
this.b = 3;
9393
}

0 commit comments

Comments
 (0)