88 lines
1.2 KiB
Text
88 lines
1.2 KiB
Text
=== tests/cases/conformance/constEnums/constEnumPropertyAccess1.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 : G
|
|
|
|
A = 1,
|
|
>A : G
|
|
>1 : number
|
|
|
|
B = 2,
|
|
>B : G
|
|
>2 : number
|
|
|
|
C = A + B,
|
|
>C : G
|
|
>A + B : number
|
|
>A : G
|
|
>B : G
|
|
|
|
D = A * 2
|
|
>D : G
|
|
>A * 2 : number
|
|
>A : G
|
|
>2 : number
|
|
}
|
|
|
|
var o: {
|
|
>o : { [idx: number]: boolean; }
|
|
|
|
[idx: number]: boolean
|
|
>idx : number
|
|
|
|
} = {
|
|
>{ 1: true } : { [x: number]: boolean; 1: boolean; }
|
|
|
|
1: true
|
|
>true : boolean
|
|
|
|
};
|
|
|
|
var a = G.A;
|
|
>a : G
|
|
>G.A : G
|
|
>G : typeof G
|
|
>A : G
|
|
|
|
var a1 = G["A"];
|
|
>a1 : G
|
|
>G["A"] : G
|
|
>G : typeof G
|
|
>"A" : string
|
|
|
|
var g = o[G.A];
|
|
>g : boolean
|
|
>o[G.A] : boolean
|
|
>o : { [idx: number]: boolean; }
|
|
>G.A : G
|
|
>G : typeof G
|
|
>A : G
|
|
|
|
class C {
|
|
>C : C
|
|
|
|
[G.A]() { }
|
|
>G.A : G
|
|
>G : typeof G
|
|
>A : G
|
|
|
|
get [G.B]() {
|
|
>G.B : G
|
|
>G : typeof G
|
|
>B : G
|
|
|
|
return true;
|
|
>true : boolean
|
|
}
|
|
set [G.B](x: number) { }
|
|
>G.B : G
|
|
>G : typeof G
|
|
>B : G
|
|
>x : number
|
|
}
|
|
|
|
|