mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
56 lines
2.0 KiB
Plaintext
56 lines
2.0 KiB
Plaintext
//// [tests/cases/conformance/constEnums/constEnumPropertyAccess2.ts] ////
|
|
|
|
=== 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))
|
|
|