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
|
//// [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 {
A = 1,
B = 2,
C = A + B,
D = A * 2
}
// Error from referring constant enum in any other context than a property access
var z = G;
var z1 = G[G.A];
var g: G;
g = "string";
function foo(x: G) { }
G.B = 3;
//// [constEnumPropertyAccess2.js]
// 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
// Error from referring constant enum in any other context than a property access
var z = G;
var z1 = G[1 /* A */];
var g;
g = "string";
function foo(x) { }
2 /* B */ = 3;
//// [constEnumPropertyAccess2.d.ts]
declare const enum G {
A = 1,
B = 2,
C = 3,
D = 2
}
declare var z: typeof G;
declare var z1: any;
declare var g: G;
declare function foo(x: G): void;
|