Skip to content

Commit 455ccce

Browse files
committed
Add tests based on #5449
1 parent 53d3921 commit 455ccce

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
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.
2+
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.
3+
4+
5+
==== tests/cases/conformance/types/thisType/thisTypeErrors2.ts (2 errors) ====
6+
class Base {
7+
constructor(a: this) {
8+
~~~~
9+
!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface.
10+
}
11+
}
12+
class Generic<T> {
13+
}
14+
class Derived {
15+
n: number;
16+
constructor(public host: Generic<this>) {
17+
~~~~
18+
!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface.
19+
this.n = 12;
20+
}
21+
}
22+
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//// [thisTypeErrors2.ts]
2+
class Base {
3+
constructor(a: this) {
4+
}
5+
}
6+
class Generic<T> {
7+
}
8+
class Derived {
9+
n: number;
10+
constructor(public host: Generic<this>) {
11+
this.n = 12;
12+
}
13+
}
14+
15+
16+
//// [thisTypeErrors2.js]
17+
var Base = (function () {
18+
function Base(a) {
19+
}
20+
return Base;
21+
})();
22+
var Generic = (function () {
23+
function Generic() {
24+
}
25+
return Generic;
26+
})();
27+
var Derived = (function () {
28+
function Derived(host) {
29+
this.host = host;
30+
this.n = 12;
31+
}
32+
return Derived;
33+
})();
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Base {
2+
constructor(a: this) {
3+
}
4+
}
5+
class Generic<T> {
6+
}
7+
class Derived {
8+
n: number;
9+
constructor(public host: Generic<this>) {
10+
this.n = 12;
11+
}
12+
}

0 commit comments

Comments
 (0)