mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 02:33:53 -06:00
Add tests based on #5449
This commit is contained in:
parent
53d392151d
commit
455cccee9c
22
tests/baselines/reference/thisTypeErrors2.errors.txt
Normal file
22
tests/baselines/reference/thisTypeErrors2.errors.txt
Normal 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;
|
||||
}
|
||||
}
|
||||
|
||||
33
tests/baselines/reference/thisTypeErrors2.js
Normal file
33
tests/baselines/reference/thisTypeErrors2.js
Normal 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;
|
||||
})();
|
||||
12
tests/cases/conformance/types/thisType/thisTypeErrors2.ts
Normal file
12
tests/cases/conformance/types/thisType/thisTypeErrors2.ts
Normal 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;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user