forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make ambiant & const enums report similar errors (allow any constant …
…number expression). fixes microsoft#2790 If an invalid enum constant expression is found, continue incrementing with the last valid initialized value. If an enum expression references another enum member, then emit a reference to the other value.
- Loading branch information
Showing
42 changed files
with
514 additions
and
212 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
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
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
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
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
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 |
---|---|---|
@@ -1,17 +1,14 @@ | ||
tests/cases/compiler/ambientEnum1.ts(2,9): error TS1066: Ambient enum elements can only have integer literal initializers. | ||
tests/cases/compiler/ambientEnum1.ts(7,9): error TS1066: Ambient enum elements can only have integer literal initializers. | ||
tests/cases/compiler/ambientEnum1.ts(7,13): error TS1066: Ambient enum initializer must be a constant expression. | ||
|
||
|
||
==== tests/cases/compiler/ambientEnum1.ts (2 errors) ==== | ||
==== tests/cases/compiler/ambientEnum1.ts (1 errors) ==== | ||
declare enum E1 { | ||
y = 4.23 | ||
~ | ||
!!! error TS1066: Ambient enum elements can only have integer literal initializers. | ||
} | ||
|
||
// Ambient enum with computer member | ||
declare enum E2 { | ||
x = 'foo'.length | ||
~ | ||
!!! error TS1066: Ambient enum elements can only have integer literal initializers. | ||
~~~~~~~~~~~~ | ||
!!! error TS1066: Ambient enum initializer must be a constant expression. | ||
} |
Oops, something went wrong.