From c5e611891bbc019f52ccf1bb618741d3a4b4f7d3 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 2 Nov 2015 10:47:56 -0800 Subject: [PATCH] Add a variable of type `this` in constructor body The test already had a reference to the `this` value, but that doesn't show that the *type* is allowed. --- tests/baselines/reference/thisTypeErrors2.errors.txt | 1 + tests/baselines/reference/thisTypeErrors2.js | 2 ++ tests/cases/conformance/types/thisType/thisTypeErrors2.ts | 1 + 3 files changed, 4 insertions(+) diff --git a/tests/baselines/reference/thisTypeErrors2.errors.txt b/tests/baselines/reference/thisTypeErrors2.errors.txt index cdb49b877df..783325f4ef3 100644 --- a/tests/baselines/reference/thisTypeErrors2.errors.txt +++ b/tests/baselines/reference/thisTypeErrors2.errors.txt @@ -16,6 +16,7 @@ tests/cases/conformance/types/thisType/thisTypeErrors2.ts(9,38): error TS2526: A constructor(public host: Generic) { ~~~~ !!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. + let self: this = this; this.n = 12; } } diff --git a/tests/baselines/reference/thisTypeErrors2.js b/tests/baselines/reference/thisTypeErrors2.js index 476e2039996..f48d0874e53 100644 --- a/tests/baselines/reference/thisTypeErrors2.js +++ b/tests/baselines/reference/thisTypeErrors2.js @@ -8,6 +8,7 @@ class Generic { class Derived { n: number; constructor(public host: Generic) { + let self: this = this; this.n = 12; } } @@ -27,6 +28,7 @@ var Generic = (function () { var Derived = (function () { function Derived(host) { this.host = host; + var self = this; this.n = 12; } return Derived; diff --git a/tests/cases/conformance/types/thisType/thisTypeErrors2.ts b/tests/cases/conformance/types/thisType/thisTypeErrors2.ts index b30a554bd88..d29e714c4d0 100644 --- a/tests/cases/conformance/types/thisType/thisTypeErrors2.ts +++ b/tests/cases/conformance/types/thisType/thisTypeErrors2.ts @@ -7,6 +7,7 @@ class Generic { class Derived { n: number; constructor(public host: Generic) { + let self: this = this; this.n = 12; } }