1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
=== tests/cases/compiler/constEnumErrors.ts ===
const enum E {
>E : E
A
>A : E.A
}
module E {
>E : typeof E
var x = 1;
>x : number
>1 : 1
}
const enum E1 {
>E1 : E1
// illegal case
// forward reference to the element of the same enum
X = Y,
>X : E1.X
>Y : E1.Y
// forward reference to the element of the same enum
Y = E1.Z,
>Y : E1.Y
>E1.Z : any
>E1 : typeof E1
>Z : any
Y1 = E1["Z"]
>Y1 : E1.Y1
>E1["Z"] : any
>E1 : typeof E1
>"Z" : "Z"
}
const enum E2 {
>E2 : E2
A
>A : E2.A
}
var y0 = E2[1]
>y0 : any
>E2[1] : any
>E2 : typeof E2
>1 : 1
var name = "A";
>name : string
>"A" : "A"
var y1 = E2[name];
>y1 : any
>E2[name] : any
>E2 : typeof E2
>name : string
var y2 = E2[`${name}`];
>y2 : any
>E2[`${name}`] : any
>E2 : typeof E2
>`${name}` : string
>name : string
var x = E2;
>x : typeof E2
>E2 : typeof E2
var y = [E2];
>y : (typeof E2)[]
>[E2] : (typeof E2)[]
>E2 : typeof E2
function foo(t: any): void {
>foo : (t: any) => void
>t : any
}
foo(E2);
>foo(E2) : void
>foo : (t: any) => void
>E2 : typeof E2
const enum NaNOrInfinity {
>NaNOrInfinity : NaNOrInfinity
A = 9007199254740992,
>A : NaNOrInfinity.A
>9007199254740992 : 9007199254740992
B = A * A,
>B : NaNOrInfinity.B
>A * A : number
>A : NaNOrInfinity.A
>A : NaNOrInfinity.A
C = B * B,
>C : NaNOrInfinity.C
>B * B : number
>B : NaNOrInfinity.B
>B : NaNOrInfinity.B
D = C * C,
>D : NaNOrInfinity.D
>C * C : number
>C : NaNOrInfinity.C
>C : NaNOrInfinity.C
E = D * D,
>E : NaNOrInfinity.E
>D * D : number
>D : NaNOrInfinity.D
>D : NaNOrInfinity.D
F = E * E, // overflow
>F : NaNOrInfinity.F
>E * E : number
>E : NaNOrInfinity.E
>E : NaNOrInfinity.E
G = 1 / 0, // overflow
>G : NaNOrInfinity.F
>1 / 0 : number
>1 : 1
>0 : 0
H = 0 / 0 // NaN
>H : NaNOrInfinity.H
>0 / 0 : number
>0 : 0
>0 : 0
}
|