Skip to content

Commit 319a9cd

Browse files
author
Yui T
committed
Update baseline with new error message number and fix space and comment
1 parent c0f818f commit 319a9cd

16 files changed

Lines changed: 45 additions & 46 deletions

src/compiler/checker.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6848,7 +6848,6 @@ namespace ts {
68486848
let container = getThisContainer(node, /* includeArrowFunctions */ true);
68496849
let needToCaptureLexicalThis = false;
68506850

6851-
68526851
if (container.kind === SyntaxKind.Constructor) {
68536852
// Keep track of whether we have seen "super" before encounter "this" so that
68546853
// we can report appropriate error later in checkConstructorDeclaration
@@ -6859,7 +6858,7 @@ namespace ts {
68596858
// (()=>this); // No Error
68606859
// super();
68616860
// }
6862-
let nodeLinks = getNodeLinks(container);
6861+
const nodeLinks = getNodeLinks(container);
68636862
nodeLinks.flags |= NodeCheckFlags.HasSeenThisCall;
68646863
}
68656864

@@ -9603,10 +9602,10 @@ namespace ts {
96039602

96049603
const signature = getResolvedSignature(node);
96059604
if (node.expression.kind === SyntaxKind.SuperKeyword) {
9606-
let containgFunction = getContainingFunction(node.expression);
9605+
const containgFunction = getContainingFunction(node.expression);
96079606

96089607
if (containgFunction && containgFunction.kind === SyntaxKind.Constructor) {
9609-
let nodeLinks = getNodeLinks(containgFunction);
9608+
const nodeLinks = getNodeLinks(containgFunction);
96109609
if (!(nodeLinks.flags & NodeCheckFlags.HasSeenThisCall)) {
96119610
nodeLinks.flags |= NodeCheckFlags.HasSeenSuperBeforeThis;
96129611
}
@@ -11211,7 +11210,7 @@ namespace ts {
1121111210
markThisReferencesAsErrors(superCallStatement.expression);
1121211211
}
1121311212
}
11214-
else if (!(getNodeCheckFlags(node) & NodeCheckFlags.HasSeenSuperBeforeThis)){
11213+
else if (!(getNodeCheckFlags(node) & NodeCheckFlags.HasSeenSuperBeforeThis)) {
1121511214
// In ES6, super inside constructor of class-declaration has to precede "this" accessing
1121611215
error(superCallStatement, Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class);
1121711216
}

src/compiler/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2030,7 +2030,7 @@ namespace ts {
20302030
BlockScopedBindingInLoop = 0x00004000,
20312031
LexicalModuleMergesWithClass = 0x00008000, // Instantiated lexical module declaration is merged with a previous class declaration.
20322032
LoopWithBlockScopedBindingCapturedInFunction = 0x00010000, // Loop that contains block scoped variable captured in closure
2033-
HasSeenSuperBeforeThis = 0x00020000, // Set during the binding if the 'super' is used before 'this' in constructor function
2033+
HasSeenSuperBeforeThis = 0x00020000, // Set during the binding if 'super' is used before 'this' in constructor function
20342034
HasSeenThisCall = 0x00040000, // Set during the binding when encounter 'this'
20352035
}
20362036

tests/baselines/reference/checkSuperCallBeforeThisAccessing1.types

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ class Derived extends Based {
1515
>super : typeof Based
1616

1717
this;
18-
>this : Derived
18+
>this : this
1919

2020
this.x = 10;
2121
>this.x = 10 : number
2222
>this.x : number
23-
>this : Derived
23+
>this : this
2424
>x : number
2525
>10 : number
2626

2727
var that = this;
28-
>that : Derived
29-
>this : Derived
28+
>that : this
29+
>this : this
3030
}
3131
}

tests/baselines/reference/checkSuperCallBeforeThisAccessing2.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
tests/cases/compiler/checkSuperCallBeforeThisAccessing2.ts(6,9): error TS17006: 'super' must be called before accessing 'this' in the constructor of a derived class.
1+
tests/cases/compiler/checkSuperCallBeforeThisAccessing2.ts(6,9): error TS17008: 'super' must be called before accessing 'this' in the constructor of a derived class.
22

33

44
==== tests/cases/compiler/checkSuperCallBeforeThisAccessing2.ts (1 errors) ====
@@ -9,7 +9,7 @@ tests/cases/compiler/checkSuperCallBeforeThisAccessing2.ts(6,9): error TS17006:
99
this.x = 100;
1010
super();
1111
~~~~~~~~
12-
!!! error TS17006: 'super' must be called before accessing 'this' in the constructor of a derived class.
12+
!!! error TS17008: 'super' must be called before accessing 'this' in the constructor of a derived class.
1313
this.x = 10;
1414
var that = this;
1515
}

tests/baselines/reference/checkSuperCallBeforeThisAccessing3.types

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Derived extends Based {
2020
this.y = true;
2121
>this.y = true : boolean
2222
>this.y : boolean
23-
>this : innver
23+
>this : this
2424
>y : boolean
2525
>true : boolean
2626
}
@@ -32,12 +32,12 @@ class Derived extends Based {
3232
this.x = 10;
3333
>this.x = 10 : number
3434
>this.x : number
35-
>this : Derived
35+
>this : this
3636
>x : number
3737
>10 : number
3838

3939
var that = this;
40-
>that : Derived
41-
>this : Derived
40+
>that : this
41+
>this : this
4242
}
4343
}

tests/baselines/reference/checkSuperCallBeforeThisAccessing4.types

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ class Derived extends Based {
1515
>() => { this; // No error } : () => void
1616

1717
this; // No error
18-
>this : Derived
18+
>this : this
1919

2020
});
2121
() => {
2222
>() => { this; // No error } : () => void
2323

2424
this; // No error
25-
>this : Derived
25+
>this : this
2626

2727
};
2828
(() => {
@@ -31,7 +31,7 @@ class Derived extends Based {
3131
>() => { this; // No error } : () => void
3232

3333
this; // No error
34-
>this : Derived
34+
>this : this
3535

3636
})();
3737
super();
@@ -45,12 +45,12 @@ class Derived extends Based {
4545
this.x = 10;
4646
>this.x = 10 : number
4747
>this.x : number
48-
>this : Derived
48+
>this : this
4949
>x : number
5050
>10 : number
5151

5252
var that = this;
53-
>that : Derived
54-
>this : Derived
53+
>that : this
54+
>this : this
5555
}
5656
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
tests/cases/compiler/checkSuperCallBeforeThisAccessing5.ts(5,9): error TS17006: 'super' must be called before accessing 'this' in the constructor of a derived class.
1+
tests/cases/compiler/checkSuperCallBeforeThisAccessing5.ts(5,9): error TS17008: 'super' must be called before accessing 'this' in the constructor of a derived class.
22

33

44
==== tests/cases/compiler/checkSuperCallBeforeThisAccessing5.ts (1 errors) ====
@@ -8,6 +8,6 @@ tests/cases/compiler/checkSuperCallBeforeThisAccessing5.ts(5,9): error TS17006:
88
constructor() {
99
super(this.x);
1010
~~~~~~~~~~~~~~
11-
!!! error TS17006: 'super' must be called before accessing 'this' in the constructor of a derived class.
11+
!!! error TS17008: 'super' must be called before accessing 'this' in the constructor of a derived class.
1212
}
1313
}

tests/baselines/reference/checkSuperCallBeforeThisAccessing6.types

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ class Super extends Base {
1212

1313
constructor() {
1414
(() => this); // No Error
15-
>(() => this) : () => Super
16-
>() => this : () => Super
17-
>this : Super
15+
>(() => this) : () => this
16+
>() => this : () => this
17+
>this : this
1818

1919
super();
2020
>super() : void

tests/baselines/reference/checkSuperCallBeforeThisAccessing7.types

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ class Super extends Base {
1515
super((() => this)); // No error
1616
>super((() => this)) : void
1717
>super : typeof Base
18-
>(() => this) : () => Super
19-
>() => this : () => Super
20-
>this : Super
18+
>(() => this) : () => this
19+
>() => this : () => this
20+
>this : this
2121
}
2222
}

tests/baselines/reference/checkSuperCallBeforeThisAccessing8.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
tests/cases/compiler/checkSuperCallBeforeThisAccessing8.ts(8,9): error TS17006: 'super' must be called before accessing 'this' in the constructor of a derived class.
1+
tests/cases/compiler/checkSuperCallBeforeThisAccessing8.ts(8,9): error TS17008: 'super' must be called before accessing 'this' in the constructor of a derived class.
22

33

44
==== tests/cases/compiler/checkSuperCallBeforeThisAccessing8.ts (1 errors) ====
@@ -11,6 +11,6 @@ tests/cases/compiler/checkSuperCallBeforeThisAccessing8.ts(8,9): error TS17006:
1111
var that = this;
1212
super();
1313
~~~~~~~~
14-
!!! error TS17006: 'super' must be called before accessing 'this' in the constructor of a derived class.
14+
!!! error TS17008: 'super' must be called before accessing 'this' in the constructor of a derived class.
1515
}
1616
}

0 commit comments

Comments
 (0)