Skip to content

Commit 4214aed

Browse files
committed
Test:static inits can refer to later static methods
1 parent 833fd01 commit 4214aed

File tree

3 files changed

+81
-0
lines changed

3 files changed

+81
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
tests/cases/compiler/scopeCheckStaticInitializer.ts(2,38): error TS2448: Block-scoped variable 'data' used before its declaration.
2+
tests/cases/compiler/scopeCheckStaticInitializer.ts(5,23): error TS2449: Class 'After' used before its declaration.
3+
tests/cases/compiler/scopeCheckStaticInitializer.ts(5,29): error TS2448: Block-scoped variable 'data' used before its declaration.
4+
tests/cases/compiler/scopeCheckStaticInitializer.ts(6,23): error TS2449: Class 'After' used before its declaration.
5+
6+
7+
==== tests/cases/compiler/scopeCheckStaticInitializer.ts (4 errors) ====
8+
class X {
9+
static illegalBeforeProperty = X.data;
10+
~~~~
11+
!!! error TS2448: Block-scoped variable 'data' used before its declaration.
12+
static okBeforeMethod = X.method;
13+
14+
static illegal2 = After.data;
15+
~~~~~
16+
!!! error TS2449: Class 'After' used before its declaration.
17+
~~~~
18+
!!! error TS2448: Block-scoped variable 'data' used before its declaration.
19+
static illegal3 = After.method;
20+
~~~~~
21+
!!! error TS2449: Class 'After' used before its declaration.
22+
static data = 13;
23+
static method() { }
24+
}
25+
class After {
26+
static data = 12;
27+
static method() { };
28+
}
29+
30+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//// [scopeCheckStaticInitializer.ts]
2+
class X {
3+
static illegalBeforeProperty = X.data;
4+
static okBeforeMethod = X.method;
5+
6+
static illegal2 = After.data;
7+
static illegal3 = After.method;
8+
static data = 13;
9+
static method() { }
10+
}
11+
class After {
12+
static data = 12;
13+
static method() { };
14+
}
15+
16+
17+
18+
//// [scopeCheckStaticInitializer.js]
19+
var X = (function () {
20+
function X() {
21+
}
22+
X.method = function () { };
23+
return X;
24+
}());
25+
X.illegalBeforeProperty = X.data;
26+
X.okBeforeMethod = X.method;
27+
X.illegal2 = After.data;
28+
X.illegal3 = After.method;
29+
X.data = 13;
30+
var After = (function () {
31+
function After() {
32+
}
33+
After.method = function () { };
34+
;
35+
return After;
36+
}());
37+
After.data = 12;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class X {
2+
static illegalBeforeProperty = X.data;
3+
static okBeforeMethod = X.method;
4+
5+
static illegal2 = After.data;
6+
static illegal3 = After.method;
7+
static data = 13;
8+
static method() { }
9+
}
10+
class After {
11+
static data = 12;
12+
static method() { };
13+
}
14+

0 commit comments

Comments
 (0)