From 669ecab631aa50939e531a3c6df0706125e813fd Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 6 Feb 2017 16:05:40 -0800 Subject: [PATCH] Test property initialiser forward reference errors --- .../forwardRefInClassProperties.errors.txt | 27 ++++++++++++++++ .../reference/forwardRefInClassProperties.js | 31 +++++++++++++++++++ .../compiler/forwardRefInClassProperties.ts | 14 +++++++++ 3 files changed, 72 insertions(+) create mode 100644 tests/baselines/reference/forwardRefInClassProperties.errors.txt create mode 100644 tests/baselines/reference/forwardRefInClassProperties.js create mode 100644 tests/cases/compiler/forwardRefInClassProperties.ts diff --git a/tests/baselines/reference/forwardRefInClassProperties.errors.txt b/tests/baselines/reference/forwardRefInClassProperties.errors.txt new file mode 100644 index 00000000000..dcf153076ed --- /dev/null +++ b/tests/baselines/reference/forwardRefInClassProperties.errors.txt @@ -0,0 +1,27 @@ +tests/cases/compiler/forwardRefInClassProperties.ts(3,15): error TS2448: Block-scoped variable '_a' used before its declaration. +tests/cases/compiler/forwardRefInClassProperties.ts(6,22): error TS2448: Block-scoped variable '_A' used before its declaration. +tests/cases/compiler/forwardRefInClassProperties.ts(11,17): error TS2448: Block-scoped variable 'b' used before its declaration. + + +==== tests/cases/compiler/forwardRefInClassProperties.ts (3 errors) ==== + class Test + { + _b = this._a; // undefined, no error/warning + ~~ +!!! error TS2448: Block-scoped variable '_a' used before its declaration. + _a = 3; + + static _B = Test._A; // undefined, no error/warning + ~~ +!!! error TS2448: Block-scoped variable '_A' used before its declaration. + static _A = 3; + + method() + { + let a = b; // Block-scoped variable 'b' used before its declaration + ~ +!!! error TS2448: Block-scoped variable 'b' used before its declaration. + let b = 3; + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/forwardRefInClassProperties.js b/tests/baselines/reference/forwardRefInClassProperties.js new file mode 100644 index 00000000000..1dc455729ab --- /dev/null +++ b/tests/baselines/reference/forwardRefInClassProperties.js @@ -0,0 +1,31 @@ +//// [forwardRefInClassProperties.ts] +class Test +{ + _b = this._a; // undefined, no error/warning + _a = 3; + + static _B = Test._A; // undefined, no error/warning + static _A = 3; + + method() + { + let a = b; // Block-scoped variable 'b' used before its declaration + let b = 3; + } +} + + +//// [forwardRefInClassProperties.js] +var Test = (function () { + function Test() { + this._b = this._a; // undefined, no error/warning + this._a = 3; + } + Test.prototype.method = function () { + var a = b; // Block-scoped variable 'b' used before its declaration + var b = 3; + }; + return Test; +}()); +Test._B = Test._A; // undefined, no error/warning +Test._A = 3; diff --git a/tests/cases/compiler/forwardRefInClassProperties.ts b/tests/cases/compiler/forwardRefInClassProperties.ts new file mode 100644 index 00000000000..80819b1a175 --- /dev/null +++ b/tests/cases/compiler/forwardRefInClassProperties.ts @@ -0,0 +1,14 @@ +class Test +{ + _b = this._a; // undefined, no error/warning + _a = 3; + + static _B = Test._A; // undefined, no error/warning + static _A = 3; + + method() + { + let a = b; // Block-scoped variable 'b' used before its declaration + let b = 3; + } +}