2018-05-03 23:00:52 +02:00
|
|
|
// @lib: es5
|
2014-10-29 08:17:16 +01:00
|
|
|
const enum E {
|
|
|
|
A
|
|
|
|
}
|
|
|
|
|
|
|
|
module E {
|
|
|
|
var x = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
const enum E1 {
|
|
|
|
// illegal case
|
|
|
|
// forward reference to the element of the same enum
|
2019-09-27 21:04:13 +02:00
|
|
|
X = Y,
|
2014-10-29 08:17:16 +01:00
|
|
|
// forward reference to the element of the same enum
|
|
|
|
Y = E1.Z,
|
|
|
|
Y1 = E1["Z"]
|
|
|
|
}
|
|
|
|
|
|
|
|
const enum E2 {
|
|
|
|
A
|
|
|
|
}
|
|
|
|
|
|
|
|
var y0 = E2[1]
|
|
|
|
var name = "A";
|
|
|
|
var y1 = E2[name];
|
2019-09-27 21:04:13 +02:00
|
|
|
var y2 = E2[`${name}`];
|
2014-10-29 08:17:16 +01:00
|
|
|
|
|
|
|
var x = E2;
|
|
|
|
var y = [E2];
|
|
|
|
|
|
|
|
function foo(t: any): void {
|
|
|
|
}
|
|
|
|
|
2014-10-30 07:21:30 +01:00
|
|
|
foo(E2);
|
|
|
|
|
|
|
|
const enum NaNOrInfinity {
|
|
|
|
A = 9007199254740992,
|
|
|
|
B = A * A,
|
|
|
|
C = B * B,
|
|
|
|
D = C * C,
|
|
|
|
E = D * D,
|
|
|
|
F = E * E, // overflow
|
|
|
|
G = 1 / 0, // overflow
|
|
|
|
H = 0 / 0 // NaN
|
|
|
|
}
|