mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-11-18 20:11:14 +00:00
Test property initialiser forward reference errors
This commit is contained in:
1 parent
c28edc31c0
commit
669ecab631
3 files changed
+72
No files matched your search
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -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