Skip to content

Commit 669ecab

Browse files
committed
Test property initialiser forward reference errors
1 parent c28edc3 commit 669ecab

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
tests/cases/compiler/forwardRefInClassProperties.ts(3,15): error TS2448: Block-scoped variable '_a' used before its declaration.
2+
tests/cases/compiler/forwardRefInClassProperties.ts(6,22): error TS2448: Block-scoped variable '_A' used before its declaration.
3+
tests/cases/compiler/forwardRefInClassProperties.ts(11,17): error TS2448: Block-scoped variable 'b' used before its declaration.
4+
5+
6+
==== tests/cases/compiler/forwardRefInClassProperties.ts (3 errors) ====
7+
class Test
8+
{
9+
_b = this._a; // undefined, no error/warning
10+
~~
11+
!!! error TS2448: Block-scoped variable '_a' used before its declaration.
12+
_a = 3;
13+
14+
static _B = Test._A; // undefined, no error/warning
15+
~~
16+
!!! error TS2448: Block-scoped variable '_A' used before its declaration.
17+
static _A = 3;
18+
19+
method()
20+
{
21+
let a = b; // Block-scoped variable 'b' used before its declaration
22+
~
23+
!!! error TS2448: Block-scoped variable 'b' used before its declaration.
24+
let b = 3;
25+
}
26+
}
27+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//// [forwardRefInClassProperties.ts]
2+
class Test
3+
{
4+
_b = this._a; // undefined, no error/warning
5+
_a = 3;
6+
7+
static _B = Test._A; // undefined, no error/warning
8+
static _A = 3;
9+
10+
method()
11+
{
12+
let a = b; // Block-scoped variable 'b' used before its declaration
13+
let b = 3;
14+
}
15+
}
16+
17+
18+
//// [forwardRefInClassProperties.js]
19+
var Test = (function () {
20+
function Test() {
21+
this._b = this._a; // undefined, no error/warning
22+
this._a = 3;
23+
}
24+
Test.prototype.method = function () {
25+
var a = b; // Block-scoped variable 'b' used before its declaration
26+
var b = 3;
27+
};
28+
return Test;
29+
}());
30+
Test._B = Test._A; // undefined, no error/warning
31+
Test._A = 3;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Test
2+
{
3+
_b = this._a; // undefined, no error/warning
4+
_a = 3;
5+
6+
static _B = Test._A; // undefined, no error/warning
7+
static _A = 3;
8+
9+
method()
10+
{
11+
let a = b; // Block-scoped variable 'b' used before its declaration
12+
let b = 3;
13+
}
14+
}

0 commit comments

Comments
 (0)