Test property initialiser forward reference errors

This commit is contained in:
Nathan Shively-Sanders
2017-02-06 16:05:40 -08:00
parent c28edc31c0
commit 669ecab631
3 changed files with 72 additions and 0 deletions

View File

@@ -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;
}
}

View File

@@ -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;

View File

@@ -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;
}
}