-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15010 from Microsoft/static-initialisers-can-refe…
…r-to-later-static-methods Static initializers may refer to later static methods
- Loading branch information
Showing
4 changed files
with
95 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
tests/baselines/reference/scopeCheckStaticInitializer.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
tests/cases/compiler/scopeCheckStaticInitializer.ts(2,38): error TS2448: Block-scoped variable 'data' used before its declaration. | ||
tests/cases/compiler/scopeCheckStaticInitializer.ts(5,23): error TS2449: Class 'After' used before its declaration. | ||
tests/cases/compiler/scopeCheckStaticInitializer.ts(5,29): error TS2448: Block-scoped variable 'data' used before its declaration. | ||
tests/cases/compiler/scopeCheckStaticInitializer.ts(6,23): error TS2449: Class 'After' used before its declaration. | ||
|
||
|
||
==== tests/cases/compiler/scopeCheckStaticInitializer.ts (4 errors) ==== | ||
class X { | ||
static illegalBeforeProperty = X.data; | ||
~~~~ | ||
!!! error TS2448: Block-scoped variable 'data' used before its declaration. | ||
static okBeforeMethod = X.method; | ||
|
||
static illegal2 = After.data; | ||
~~~~~ | ||
!!! error TS2449: Class 'After' used before its declaration. | ||
~~~~ | ||
!!! error TS2448: Block-scoped variable 'data' used before its declaration. | ||
static illegal3 = After.method; | ||
~~~~~ | ||
!!! error TS2449: Class 'After' used before its declaration. | ||
static data = 13; | ||
static method() { } | ||
} | ||
class After { | ||
static data = 12; | ||
static method() { }; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
//// [scopeCheckStaticInitializer.ts] | ||
class X { | ||
static illegalBeforeProperty = X.data; | ||
static okBeforeMethod = X.method; | ||
|
||
static illegal2 = After.data; | ||
static illegal3 = After.method; | ||
static data = 13; | ||
static method() { } | ||
} | ||
class After { | ||
static data = 12; | ||
static method() { }; | ||
} | ||
|
||
|
||
|
||
//// [scopeCheckStaticInitializer.js] | ||
var X = (function () { | ||
function X() { | ||
} | ||
X.method = function () { }; | ||
return X; | ||
}()); | ||
X.illegalBeforeProperty = X.data; | ||
X.okBeforeMethod = X.method; | ||
X.illegal2 = After.data; | ||
X.illegal3 = After.method; | ||
X.data = 13; | ||
var After = (function () { | ||
function After() { | ||
} | ||
After.method = function () { }; | ||
; | ||
return After; | ||
}()); | ||
After.data = 12; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class X { | ||
static illegalBeforeProperty = X.data; | ||
static okBeforeMethod = X.method; | ||
|
||
static illegal2 = After.data; | ||
static illegal3 = After.method; | ||
static data = 13; | ||
static method() { } | ||
} | ||
class After { | ||
static data = 12; | ||
static method() { }; | ||
} | ||
|