Add tests based on #5449

This commit is contained in:
Nathan Shively-Sanders 2015-10-30 14:02:07 -07:00
parent 53d392151d
commit 455cccee9c
3 changed files with 67 additions and 0 deletions

View File

@ -0,0 +1,22 @@
tests/cases/conformance/types/thisType/thisTypeErrors2.ts(2,20): error TS2526: A 'this' type is available only in a non-static member of a class or interface.
tests/cases/conformance/types/thisType/thisTypeErrors2.ts(9,38): error TS2526: A 'this' type is available only in a non-static member of a class or interface.
==== tests/cases/conformance/types/thisType/thisTypeErrors2.ts (2 errors) ====
class Base {
constructor(a: this) {
~~~~
!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface.
}
}
class Generic<T> {
}
class Derived {
n: number;
constructor(public host: Generic<this>) {
~~~~
!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface.
this.n = 12;
}
}

View File

@ -0,0 +1,33 @@
//// [thisTypeErrors2.ts]
class Base {
constructor(a: this) {
}
}
class Generic<T> {
}
class Derived {
n: number;
constructor(public host: Generic<this>) {
this.n = 12;
}
}
//// [thisTypeErrors2.js]
var Base = (function () {
function Base(a) {
}
return Base;
})();
var Generic = (function () {
function Generic() {
}
return Generic;
})();
var Derived = (function () {
function Derived(host) {
this.host = host;
this.n = 12;
}
return Derived;
})();

View File

@ -0,0 +1,12 @@
class Base {
constructor(a: this) {
}
}
class Generic<T> {
}
class Derived {
n: number;
constructor(public host: Generic<this>) {
this.n = 12;
}
}