Skip to content

Commit

Permalink
Remove unused param and unnecessary baseline comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Goldberg committed Jan 13, 2022
1 parent 39d9901 commit 1b3dd6d
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 41 deletions.
13 changes: 3 additions & 10 deletions src/compiler/transformers/classFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1371,11 +1371,9 @@ namespace ts {
*
* @param properties An array of property declarations to transform.
* @param receiver The receiver on which each property should be assigned.
* @param insertionIndex How far after a found property to splice the expression statement, if not the end of the array.
*/
function addPropertyOrClassStaticBlockStatements(statements: Statement[], properties: readonly (PropertyDeclaration | ClassStaticBlockDeclaration)[], receiver: LeftHandSideExpression, insertionIndex?: number) {
for (let i = 0; i < properties.length; i += 1) {
const property = properties[i];
function addPropertyOrClassStaticBlockStatements(statements: Statement[], properties: readonly (PropertyDeclaration | ClassStaticBlockDeclaration)[], receiver: LeftHandSideExpression) {
for (const property of properties) {
const expression = isClassStaticBlockDeclaration(property) ?
transformClassStaticBlockDeclaration(property) :
transformProperty(property, receiver);
Expand All @@ -1393,12 +1391,7 @@ namespace ts {
setSyntheticLeadingComments(expression, undefined);
setSyntheticTrailingComments(expression, undefined);

if (insertionIndex !== undefined) {
statements.splice(i + insertionIndex, 0, statement);
}
else {
statements.push(statement);
}
statements.push(statement);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassP
class Derived extends Base {
constructor(y: string) {
var a = 1;
super(); // ok
super();
}
}

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

class Derived3 extends Base {
constructor(public y: string) {
super(); // ok
super();
var a = 1;
}
}
Expand All @@ -46,7 +46,7 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassP
class Derived5 extends Base {
a = 1;
constructor(y: string) {
super(); // ok
super();
var b = 2;
}
}
Expand All @@ -58,7 +58,7 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassP
~~~~
!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
var b = 2;
super(); // error: "super" has to be called before "this" accessing
super();
}
}

Expand Down Expand Up @@ -86,7 +86,7 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassP
a = 1;
b: number;
constructor(y: string) {
super(); // ok
super();
this.a = 3;
this.b = 3;
}
Expand Down Expand Up @@ -119,7 +119,7 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassP
a = 1;
b: number;
constructor(y: string) {
super(); // ok
super();
this.a = 3;
this.b = 3;
}
Expand Down
14 changes: 7 additions & 7 deletions tests/baselines/reference/derivedClassParameterProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Base {
class Derived extends Base {
constructor(y: string) {
var a = 1;
super(); // ok
super();
}
}

Expand All @@ -21,7 +21,7 @@ class Derived2 extends Base {

class Derived3 extends Base {
constructor(public y: string) {
super(); // ok
super();
var a = 1;
}
}
Expand All @@ -37,7 +37,7 @@ class Derived4 extends Base {
class Derived5 extends Base {
a = 1;
constructor(y: string) {
super(); // ok
super();
var b = 2;
}
}
Expand All @@ -47,7 +47,7 @@ class Derived6 extends Base {
constructor(y: string) {
this.a = 1;
var b = 2;
super(); // error: "super" has to be called before "this" accessing
super();
}
}

Expand All @@ -65,7 +65,7 @@ class Derived8 extends Base {
a = 1;
b: number;
constructor(y: string) {
super(); // ok
super();
this.a = 3;
this.b = 3;
}
Expand All @@ -88,7 +88,7 @@ class Derived10<T> extends Base2<T> {
a = 1;
b: number;
constructor(y: string) {
super(); // ok
super();
this.a = 3;
this.b = 3;
}
Expand Down Expand Up @@ -172,7 +172,7 @@ var Derived6 = /** @class */ (function (_super) {
var _this = this;
_this.a = 1;
var b = 2;
_this = _super.call(this) || this; // error: "super" has to be called before "this" accessing
_this = _super.call(this) || this;
return _this;
}
return Derived6;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Derived extends Base {
var a = 1;
>a : Symbol(a, Decl(derivedClassParameterProperties.ts, 8, 11))

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

super(); // ok
super();
>super : Symbol(Base, Decl(derivedClassParameterProperties.ts, 0, 0))

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

super(); // ok
super();
>super : Symbol(Base, Decl(derivedClassParameterProperties.ts, 0, 0))

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

super(); // error: "super" has to be called before "this" accessing
super();
>super : Symbol(Base, Decl(derivedClassParameterProperties.ts, 0, 0))
}
}
Expand Down Expand Up @@ -153,7 +153,7 @@ class Derived8 extends Base {
constructor(y: string) {
>y : Symbol(y, Decl(derivedClassParameterProperties.ts, 65, 16))

super(); // ok
super();
>super : Symbol(Base, Decl(derivedClassParameterProperties.ts, 0, 0))

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

super(); // ok
super();
>super : Symbol(Base2, Decl(derivedClassParameterProperties.ts, 70, 1))

this.a = 3;
Expand Down
12 changes: 6 additions & 6 deletions tests/baselines/reference/derivedClassParameterProperties.types
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Derived extends Base {
>a : number
>1 : 1

super(); // ok
super();
>super() : void
>super : typeof Base
}
Expand Down Expand Up @@ -49,7 +49,7 @@ class Derived3 extends Base {
constructor(public y: string) {
>y : string

super(); // ok
super();
>super() : void
>super : typeof Base

Expand Down Expand Up @@ -91,7 +91,7 @@ class Derived5 extends Base {
constructor(y: string) {
>y : string

super(); // ok
super();
>super() : void
>super : typeof Base

Expand Down Expand Up @@ -122,7 +122,7 @@ class Derived6 extends Base {
>b : number
>2 : 2

super(); // error: "super" has to be called before "this" accessing
super();
>super() : void
>super : typeof Base
}
Expand Down Expand Up @@ -176,7 +176,7 @@ class Derived8 extends Base {
constructor(y: string) {
>y : string

super(); // ok
super();
>super() : void
>super : typeof Base

Expand Down Expand Up @@ -249,7 +249,7 @@ class Derived10<T> extends Base2<T> {
constructor(y: string) {
>y : string

super(); // ok
super();
>super() : void
>super : typeof Base2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Base {
class Derived extends Base {
constructor(y: string) {
var a = 1;
super(); // ok
super();
}
}

Expand All @@ -20,7 +20,7 @@ class Derived2 extends Base {

class Derived3 extends Base {
constructor(public y: string) {
super(); // ok
super();
var a = 1;
}
}
Expand All @@ -36,7 +36,7 @@ class Derived4 extends Base {
class Derived5 extends Base {
a = 1;
constructor(y: string) {
super(); // ok
super();
var b = 2;
}
}
Expand All @@ -46,7 +46,7 @@ class Derived6 extends Base {
constructor(y: string) {
this.a = 1;
var b = 2;
super(); // error: "super" has to be called before "this" accessing
super();
}
}

Expand All @@ -64,7 +64,7 @@ class Derived8 extends Base {
a = 1;
b: number;
constructor(y: string) {
super(); // ok
super();
this.a = 3;
this.b = 3;
}
Expand All @@ -87,7 +87,7 @@ class Derived10<T> extends Base2<T> {
a = 1;
b: number;
constructor(y: string) {
super(); // ok
super();
this.a = 3;
this.b = 3;
}
Expand Down

0 comments on commit 1b3dd6d

Please sign in to comment.