2014-07-13 01:04:16 +02:00
|
|
|
//// [enumBasics1.ts]
|
|
|
|
enum E {
|
|
|
|
A = 1,
|
|
|
|
B,
|
|
|
|
C
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
var a: E;
|
|
|
|
var b = E["B"]; // shouldn't error
|
|
|
|
|
|
|
|
|
|
|
|
function foo(e: E) {}
|
|
|
|
|
|
|
|
foo(a); // shouldn't error
|
|
|
|
|
|
|
|
|
|
|
|
class C {
|
|
|
|
public e: E;
|
|
|
|
|
|
|
|
public m(): E { return this.e; } // shouldn't error
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var e = E; // shouldn't error
|
|
|
|
*/
|
|
|
|
E.A.A; // should error
|
|
|
|
|
|
|
|
|
|
|
|
enum E2 {
|
|
|
|
A,
|
|
|
|
B,
|
|
|
|
}
|
|
|
|
|
2014-07-16 01:20:50 +02:00
|
|
|
enum E2 { // should error for continued autonumbering
|
2014-07-13 01:04:16 +02:00
|
|
|
C,
|
|
|
|
D,
|
|
|
|
}
|
|
|
|
|
|
|
|
//// [enumBasics1.js]
|
|
|
|
var E;
|
|
|
|
(function (E) {
|
|
|
|
E[E["A"] = 1] = "A";
|
|
|
|
E[E["B"] = 2] = "B";
|
|
|
|
E[E["C"] = 3] = "C";
|
|
|
|
})(E || (E = {}));
|
2014-08-18 22:44:18 +02:00
|
|
|
/*
|
|
|
|
var a: E;
|
|
|
|
var b = E["B"]; // shouldn't error
|
|
|
|
|
|
|
|
|
|
|
|
function foo(e: E) {}
|
|
|
|
|
|
|
|
foo(a); // shouldn't error
|
|
|
|
|
|
|
|
|
|
|
|
class C {
|
2014-08-30 05:49:47 +02:00
|
|
|
public e: E;
|
2014-08-18 22:44:18 +02:00
|
|
|
|
2014-08-30 05:49:47 +02:00
|
|
|
public m(): E { return this.e; } // shouldn't error
|
2014-08-18 22:44:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var e = E; // shouldn't error
|
2014-08-16 00:49:09 +02:00
|
|
|
*/
|
|
|
|
1 /* A */.A; // should error
|
2014-07-13 01:04:16 +02:00
|
|
|
var E2;
|
|
|
|
(function (E2) {
|
|
|
|
E2[E2["A"] = 0] = "A";
|
|
|
|
E2[E2["B"] = 1] = "B";
|
|
|
|
})(E2 || (E2 = {}));
|
|
|
|
var E2;
|
|
|
|
(function (E2) {
|
|
|
|
E2[E2["C"] = 0] = "C";
|
|
|
|
E2[E2["D"] = 1] = "D";
|
|
|
|
})(E2 || (E2 = {}));
|