-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Reissue used before declaration error for const enums in isolatedModules
#57174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
andrewbranch
merged 2 commits into
microsoft:main
from
Andarist:fix/error-use-before-define-const-enum-isolated-modules
Jan 30, 2024
+464
−3
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
33 changes: 33 additions & 0 deletions
33
tests/baselines/reference/blockScopedEnumVariablesUseBeforeDef_isolatedModules.errors.txt
This file contains hidden or 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,33 @@ | ||
blockScopedEnumVariablesUseBeforeDef_isolatedModules.ts(2,12): error TS2450: Enum 'E' used before its declaration. | ||
blockScopedEnumVariablesUseBeforeDef_isolatedModules.ts(7,12): error TS2450: Enum 'E' used before its declaration. | ||
blockScopedEnumVariablesUseBeforeDef_isolatedModules.ts(12,8): error TS2450: Enum 'AfterObject' used before its declaration. | ||
|
||
|
||
==== blockScopedEnumVariablesUseBeforeDef_isolatedModules.ts (3 errors) ==== | ||
function foo1() { | ||
return E.A | ||
~ | ||
!!! error TS2450: Enum 'E' used before its declaration. | ||
!!! related TS2728 blockScopedEnumVariablesUseBeforeDef_isolatedModules.ts:3:10: 'E' is declared here. | ||
enum E { A } | ||
} | ||
|
||
function foo2() { | ||
return E.A | ||
~ | ||
!!! error TS2450: Enum 'E' used before its declaration. | ||
!!! related TS2728 blockScopedEnumVariablesUseBeforeDef_isolatedModules.ts:8:16: 'E' is declared here. | ||
const enum E { A } | ||
} | ||
|
||
const config = { | ||
a: AfterObject.A, | ||
~~~~~~~~~~~ | ||
!!! error TS2450: Enum 'AfterObject' used before its declaration. | ||
!!! related TS2728 blockScopedEnumVariablesUseBeforeDef_isolatedModules.ts:15:12: 'AfterObject' is declared here. | ||
}; | ||
|
||
const enum AfterObject { | ||
A = 2, | ||
} | ||
|
44 changes: 44 additions & 0 deletions
44
tests/baselines/reference/blockScopedEnumVariablesUseBeforeDef_isolatedModules.js
This file contains hidden or 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,44 @@ | ||
//// [tests/cases/compiler/blockScopedEnumVariablesUseBeforeDef_isolatedModules.ts] //// | ||
|
||
//// [blockScopedEnumVariablesUseBeforeDef_isolatedModules.ts] | ||
function foo1() { | ||
return E.A | ||
enum E { A } | ||
} | ||
|
||
function foo2() { | ||
return E.A | ||
const enum E { A } | ||
} | ||
|
||
const config = { | ||
a: AfterObject.A, | ||
}; | ||
|
||
const enum AfterObject { | ||
A = 2, | ||
} | ||
|
||
|
||
//// [blockScopedEnumVariablesUseBeforeDef_isolatedModules.js] | ||
function foo1() { | ||
return E.A; | ||
var E; | ||
(function (E) { | ||
E[E["A"] = 0] = "A"; | ||
})(E || (E = {})); | ||
} | ||
function foo2() { | ||
return E.A; | ||
var E; | ||
(function (E) { | ||
E[E["A"] = 0] = "A"; | ||
})(E || (E = {})); | ||
} | ||
var config = { | ||
a: AfterObject.A, | ||
}; | ||
var AfterObject; | ||
(function (AfterObject) { | ||
AfterObject[AfterObject["A"] = 2] = "A"; | ||
})(AfterObject || (AfterObject = {})); |
47 changes: 47 additions & 0 deletions
47
tests/baselines/reference/blockScopedEnumVariablesUseBeforeDef_isolatedModules.symbols
This file contains hidden or 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,47 @@ | ||
//// [tests/cases/compiler/blockScopedEnumVariablesUseBeforeDef_isolatedModules.ts] //// | ||
|
||
=== blockScopedEnumVariablesUseBeforeDef_isolatedModules.ts === | ||
function foo1() { | ||
>foo1 : Symbol(foo1, Decl(blockScopedEnumVariablesUseBeforeDef_isolatedModules.ts, 0, 0)) | ||
|
||
return E.A | ||
>E.A : Symbol(E.A, Decl(blockScopedEnumVariablesUseBeforeDef_isolatedModules.ts, 2, 12)) | ||
>E : Symbol(E, Decl(blockScopedEnumVariablesUseBeforeDef_isolatedModules.ts, 1, 14)) | ||
>A : Symbol(E.A, Decl(blockScopedEnumVariablesUseBeforeDef_isolatedModules.ts, 2, 12)) | ||
|
||
enum E { A } | ||
>E : Symbol(E, Decl(blockScopedEnumVariablesUseBeforeDef_isolatedModules.ts, 1, 14)) | ||
>A : Symbol(E.A, Decl(blockScopedEnumVariablesUseBeforeDef_isolatedModules.ts, 2, 12)) | ||
} | ||
|
||
function foo2() { | ||
>foo2 : Symbol(foo2, Decl(blockScopedEnumVariablesUseBeforeDef_isolatedModules.ts, 3, 1)) | ||
|
||
return E.A | ||
>E.A : Symbol(E.A, Decl(blockScopedEnumVariablesUseBeforeDef_isolatedModules.ts, 7, 18)) | ||
>E : Symbol(E, Decl(blockScopedEnumVariablesUseBeforeDef_isolatedModules.ts, 6, 14)) | ||
>A : Symbol(E.A, Decl(blockScopedEnumVariablesUseBeforeDef_isolatedModules.ts, 7, 18)) | ||
|
||
const enum E { A } | ||
>E : Symbol(E, Decl(blockScopedEnumVariablesUseBeforeDef_isolatedModules.ts, 6, 14)) | ||
>A : Symbol(E.A, Decl(blockScopedEnumVariablesUseBeforeDef_isolatedModules.ts, 7, 18)) | ||
} | ||
|
||
const config = { | ||
>config : Symbol(config, Decl(blockScopedEnumVariablesUseBeforeDef_isolatedModules.ts, 10, 5)) | ||
|
||
a: AfterObject.A, | ||
>a : Symbol(a, Decl(blockScopedEnumVariablesUseBeforeDef_isolatedModules.ts, 10, 16)) | ||
>AfterObject.A : Symbol(AfterObject.A, Decl(blockScopedEnumVariablesUseBeforeDef_isolatedModules.ts, 14, 24)) | ||
>AfterObject : Symbol(AfterObject, Decl(blockScopedEnumVariablesUseBeforeDef_isolatedModules.ts, 12, 2)) | ||
>A : Symbol(AfterObject.A, Decl(blockScopedEnumVariablesUseBeforeDef_isolatedModules.ts, 14, 24)) | ||
|
||
}; | ||
|
||
const enum AfterObject { | ||
>AfterObject : Symbol(AfterObject, Decl(blockScopedEnumVariablesUseBeforeDef_isolatedModules.ts, 12, 2)) | ||
|
||
A = 2, | ||
>A : Symbol(AfterObject.A, Decl(blockScopedEnumVariablesUseBeforeDef_isolatedModules.ts, 14, 24)) | ||
} | ||
|
49 changes: 49 additions & 0 deletions
49
tests/baselines/reference/blockScopedEnumVariablesUseBeforeDef_isolatedModules.types
This file contains hidden or 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,49 @@ | ||
//// [tests/cases/compiler/blockScopedEnumVariablesUseBeforeDef_isolatedModules.ts] //// | ||
|
||
=== blockScopedEnumVariablesUseBeforeDef_isolatedModules.ts === | ||
function foo1() { | ||
>foo1 : () => E | ||
|
||
return E.A | ||
>E.A : E | ||
>E : typeof E | ||
>A : E | ||
|
||
enum E { A } | ||
>E : E | ||
>A : E.A | ||
} | ||
|
||
function foo2() { | ||
>foo2 : () => E | ||
|
||
return E.A | ||
>E.A : E | ||
>E : typeof E | ||
>A : E | ||
|
||
const enum E { A } | ||
>E : E | ||
>A : E.A | ||
} | ||
|
||
const config = { | ||
>config : { a: AfterObject; } | ||
>{ a: AfterObject.A,} : { a: AfterObject; } | ||
|
||
a: AfterObject.A, | ||
>a : AfterObject | ||
>AfterObject.A : AfterObject | ||
>AfterObject : typeof AfterObject | ||
>A : AfterObject | ||
|
||
}; | ||
|
||
const enum AfterObject { | ||
>AfterObject : AfterObject | ||
|
||
A = 2, | ||
>A : AfterObject.A | ||
>2 : 2 | ||
} | ||
|
33 changes: 33 additions & 0 deletions
33
.../baselines/reference/blockScopedEnumVariablesUseBeforeDef_verbatimModuleSyntax.errors.txt
This file contains hidden or 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,33 @@ | ||
blockScopedEnumVariablesUseBeforeDef_verbatimModuleSyntax.ts(2,12): error TS2450: Enum 'E' used before its declaration. | ||
blockScopedEnumVariablesUseBeforeDef_verbatimModuleSyntax.ts(7,12): error TS2450: Enum 'E' used before its declaration. | ||
blockScopedEnumVariablesUseBeforeDef_verbatimModuleSyntax.ts(12,8): error TS2450: Enum 'AfterObject' used before its declaration. | ||
|
||
|
||
==== blockScopedEnumVariablesUseBeforeDef_verbatimModuleSyntax.ts (3 errors) ==== | ||
function foo1() { | ||
return E.A | ||
~ | ||
!!! error TS2450: Enum 'E' used before its declaration. | ||
!!! related TS2728 blockScopedEnumVariablesUseBeforeDef_verbatimModuleSyntax.ts:3:10: 'E' is declared here. | ||
enum E { A } | ||
} | ||
|
||
function foo2() { | ||
return E.A | ||
~ | ||
!!! error TS2450: Enum 'E' used before its declaration. | ||
!!! related TS2728 blockScopedEnumVariablesUseBeforeDef_verbatimModuleSyntax.ts:8:16: 'E' is declared here. | ||
const enum E { A } | ||
} | ||
|
||
const config = { | ||
a: AfterObject.A, | ||
~~~~~~~~~~~ | ||
!!! error TS2450: Enum 'AfterObject' used before its declaration. | ||
!!! related TS2728 blockScopedEnumVariablesUseBeforeDef_verbatimModuleSyntax.ts:15:12: 'AfterObject' is declared here. | ||
}; | ||
|
||
const enum AfterObject { | ||
A = 2, | ||
} | ||
|
44 changes: 44 additions & 0 deletions
44
tests/baselines/reference/blockScopedEnumVariablesUseBeforeDef_verbatimModuleSyntax.js
This file contains hidden or 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,44 @@ | ||
//// [tests/cases/compiler/blockScopedEnumVariablesUseBeforeDef_verbatimModuleSyntax.ts] //// | ||
|
||
//// [blockScopedEnumVariablesUseBeforeDef_verbatimModuleSyntax.ts] | ||
function foo1() { | ||
return E.A | ||
enum E { A } | ||
} | ||
|
||
function foo2() { | ||
return E.A | ||
const enum E { A } | ||
} | ||
|
||
const config = { | ||
a: AfterObject.A, | ||
}; | ||
|
||
const enum AfterObject { | ||
A = 2, | ||
} | ||
|
||
|
||
//// [blockScopedEnumVariablesUseBeforeDef_verbatimModuleSyntax.js] | ||
function foo1() { | ||
return E.A; | ||
var E; | ||
(function (E) { | ||
E[E["A"] = 0] = "A"; | ||
})(E || (E = {})); | ||
} | ||
function foo2() { | ||
return E.A; | ||
var E; | ||
(function (E) { | ||
E[E["A"] = 0] = "A"; | ||
})(E || (E = {})); | ||
} | ||
var config = { | ||
a: AfterObject.A, | ||
}; | ||
var AfterObject; | ||
(function (AfterObject) { | ||
AfterObject[AfterObject["A"] = 2] = "A"; | ||
})(AfterObject || (AfterObject = {})); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would commit this suggestion for you and approve, but GitHub can't handle this on checker.ts 🥲
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🫠
I pushed out the change + the relevant missing test case for
verbatimModuleSyntax
:p