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:
Nathan Shively-Sanders 2015-11-02 10:47:56 -08:00
parent 201266b97f
commit 67b9647069
3 changed files with 4 additions and 0 deletions

View file

@ -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;
}
}

View file

@ -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;

View file

@ -7,6 +7,7 @@ class Generic<T> {
class Derived {
n: number;
constructor(public host: Generic<this>) {
let self: this = this;
this.n = 12;
}
}