Skip to content

Commit

Permalink
Add tests based on #5449
Browse files Browse the repository at this point in the history
  • Loading branch information
sandersn committed Oct 30, 2015
1 parent c82d4a6 commit e609047
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/baselines/reference/thisTypeErrors2.errors.txt
Original file line number Diff line number Diff line change
@@ -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;
}
}

33 changes: 33 additions & 0 deletions tests/baselines/reference/thisTypeErrors2.js
Original file line number Diff line number Diff line change
@@ -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;
})();
12 changes: 12 additions & 0 deletions tests/cases/conformance/types/thisType/thisTypeErrors2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Base {
constructor(a: this) {
}
}
class Generic<T> {
}
class Derived {
n: number;
constructor(public host: Generic<this>) {
this.n = 12;
}
}

0 comments on commit e609047

Please sign in to comment.