mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-05 16:54:54 -05:00
Test property initialiser forward reference errors
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
31
tests/baselines/reference/forwardRefInClassProperties.js
Normal file
31
tests/baselines/reference/forwardRefInClassProperties.js
Normal 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;
|
||||
14
tests/cases/compiler/forwardRefInClassProperties.ts
Normal file
14
tests/cases/compiler/forwardRefInClassProperties.ts
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user