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.
This commit is contained in:
parent
201266b97f
commit
67b9647069
|
@ -16,6 +16,7 @@ tests/cases/conformance/types/thisType/thisTypeErrors2.ts(9,38): error TS2526: A
|
|||
constructor(public host: Generic<this>) {
|
||||
~~~~
|
||||
!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface.
|
||||
let self: this = this;
|
||||
this.n = 12;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ class Generic<T> {
|
|||
class Derived {
|
||||
n: number;
|
||||
constructor(public host: Generic<this>) {
|
||||
let self: this = this;
|
||||
this.n = 12;
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +28,7 @@ var Generic = (function () {
|
|||
var Derived = (function () {
|
||||
function Derived(host) {
|
||||
this.host = host;
|
||||
var self = this;
|
||||
this.n = 12;
|
||||
}
|
||||
return Derived;
|
||||
|
|
|
@ -7,6 +7,7 @@ class Generic<T> {
|
|||
class Derived {
|
||||
n: number;
|
||||
constructor(public host: Generic<this>) {
|
||||
let self: this = this;
|
||||
this.n = 12;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue