-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |