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
|
=== tests/cases/conformance/constEnums/constEnumPropertyAccess2.ts ===
// constant enum declarations are completely erased in the emitted JavaScript code.
// it is an error to reference a constant enum object in any other context
// than a property access that selects one of the enum's members
const enum G {
>G : Symbol(G, Decl(constEnumPropertyAccess2.ts, 0, 0))
A = 1,
>A : Symbol(G.A, Decl(constEnumPropertyAccess2.ts, 4, 14))
B = 2,
>B : Symbol(G.B, Decl(constEnumPropertyAccess2.ts, 5, 10))
C = A + B,
>C : Symbol(G.C, Decl(constEnumPropertyAccess2.ts, 6, 10))
>A : Symbol(G.A, Decl(constEnumPropertyAccess2.ts, 4, 14))
>B : Symbol(G.B, Decl(constEnumPropertyAccess2.ts, 5, 10))
D = A * 2
>D : Symbol(G.D, Decl(constEnumPropertyAccess2.ts, 7, 14))
>A : Symbol(G.A, Decl(constEnumPropertyAccess2.ts, 4, 14))
}
// Error from referring constant enum in any other context than a property access
var z = G;
>z : Symbol(z, Decl(constEnumPropertyAccess2.ts, 12, 3))
>G : Symbol(G, Decl(constEnumPropertyAccess2.ts, 0, 0))
var z1 = G[G.A];
>z1 : Symbol(z1, Decl(constEnumPropertyAccess2.ts, 13, 3))
>G : Symbol(G, Decl(constEnumPropertyAccess2.ts, 0, 0))
>G.A : Symbol(G.A, Decl(constEnumPropertyAccess2.ts, 4, 14))
>G : Symbol(G, Decl(constEnumPropertyAccess2.ts, 0, 0))
>A : Symbol(G.A, Decl(constEnumPropertyAccess2.ts, 4, 14))
var g: G;
>g : Symbol(g, Decl(constEnumPropertyAccess2.ts, 14, 3))
>G : Symbol(G, Decl(constEnumPropertyAccess2.ts, 0, 0))
g = "string";
>g : Symbol(g, Decl(constEnumPropertyAccess2.ts, 14, 3))
function foo(x: G) { }
>foo : Symbol(foo, Decl(constEnumPropertyAccess2.ts, 15, 13))
>x : Symbol(x, Decl(constEnumPropertyAccess2.ts, 16, 13))
>G : Symbol(G, Decl(constEnumPropertyAccess2.ts, 0, 0))
G.B = 3;
>G.B : Symbol(G.B, Decl(constEnumPropertyAccess2.ts, 5, 10))
>G : Symbol(G, Decl(constEnumPropertyAccess2.ts, 0, 0))
>B : Symbol(G.B, Decl(constEnumPropertyAccess2.ts, 5, 10))
|