Skip to content

Commit 67b9647

Browse files
committed
Add a variable of type this in constructor body
The test already had a reference to the `this` value, but that doesn't show that the *type* is allowed.
1 parent 201266b commit 67b9647

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

tests/baselines/reference/thisTypeErrors2.errors.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ tests/cases/conformance/types/thisType/thisTypeErrors2.ts(9,38): error TS2526: A
1616
constructor(public host: Generic<this>) {
1717
~~~~
1818
!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface.
19+
let self: this = this;
1920
this.n = 12;
2021
}
2122
}

tests/baselines/reference/thisTypeErrors2.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class Generic<T> {
88
class Derived {
99
n: number;
1010
constructor(public host: Generic<this>) {
11+
let self: this = this;
1112
this.n = 12;
1213
}
1314
}
@@ -27,6 +28,7 @@ var Generic = (function () {
2728
var Derived = (function () {
2829
function Derived(host) {
2930
this.host = host;
31+
var self = this;
3032
this.n = 12;
3133
}
3234
return Derived;

tests/cases/conformance/types/thisType/thisTypeErrors2.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class Generic<T> {
77
class Derived {
88
n: number;
99
constructor(public host: Generic<this>) {
10+
let self: this = this;
1011
this.n = 12;
1112
}
1213
}

0 commit comments

Comments
 (0)