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
|
tests/cases/conformance/constEnums/constEnumPropertyAccess1.ts(25,9): error TS2322: Type 'boolean' is not assignable to type 'number'.
==== tests/cases/conformance/constEnums/constEnumPropertyAccess1.ts (1 errors) ====
// 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
}
var o: {
[idx: number]: boolean
} = {
1: true
};
var a = G.A;
var a1 = G["A"];
var g = o[G.A];
class C {
[G.A]() { }
get [G.B]() {
return true;
~~~~~~~~~~~~
!!! error TS2322: Type 'boolean' is not assignable to type 'number'.
}
set [G.B](x: number) { }
}
|