-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
Description
TypeScript Version: nightly (2.1.0-dev.20161028)
Code
const v: Color = Color.Green;
enum Color { Red, Green, Blue }
which compiles to
var v = Color.Green;
var Color;
(function (Color) {
Color[Color["Red"] = 0] = "Red";
Color[Color["Green"] = 1] = "Green";
Color[Color["Blue"] = 2] = "Blue";
})(Color || (Color = {}));
Expected behavior:
Error on line 1: Enum Color used before its declaration.
Actual behavior:
No compiler error. Run-time error: Uncaught TypeError: Cannot read property 'Green' of undefined
Comments:
Rearranged compiler output would also be ok instead of an error:
var Color;
(function (Color) {
Color[Color["Red"] = 0] = "Red";
Color[Color["Green"] = 1] = "Green";
Color[Color["Blue"] = 2] = "Blue";
})(Color || (Color = {}));
var v = Color.Green;
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue