TypeScript/tests/baselines/reference/constEnumPropertyAccess1.types

89 lines
1.2 KiB
Plaintext
Raw Normal View History

2015-04-16 03:12:39 +02:00
=== 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 {
2015-04-17 08:25:52 +02:00
>G : G
2015-04-16 03:12:39 +02:00
A = 1,
2015-04-17 08:25:52 +02:00
>A : G
2015-04-16 03:12:39 +02:00
>1 : number
B = 2,
2015-04-17 08:25:52 +02:00
>B : G
2015-04-16 03:12:39 +02:00
>2 : number
C = A + B,
2015-04-17 08:25:52 +02:00
>C : G
2015-04-16 03:12:39 +02:00
>A + B : number
2015-04-17 08:25:52 +02:00
>A : G
>B : G
2015-04-16 03:12:39 +02:00
D = A * 2
2015-04-17 08:25:52 +02:00
>D : G
2015-04-16 03:12:39 +02:00
>A * 2 : number
2015-04-17 08:25:52 +02:00
>A : G
2015-04-16 03:12:39 +02:00
>2 : number
}
var o: {
2015-04-17 08:25:52 +02:00
>o : { [idx: number]: boolean; }
2015-04-16 03:12:39 +02:00
[idx: number]: boolean
2015-04-17 08:25:52 +02:00
>idx : number
2015-04-16 03:12:39 +02:00
} = {
>{ 1: true } : { [x: number]: boolean; 1: boolean; }
1: true
>true : boolean
};
var a = G.A;
2015-04-17 08:25:52 +02:00
>a : G
>G.A : G
>G : typeof G
>A : G
2015-04-16 03:12:39 +02:00
var a1 = G["A"];
2015-04-17 08:25:52 +02:00
>a1 : G
2015-04-16 03:12:39 +02:00
>G["A"] : G
2015-04-17 08:25:52 +02:00
>G : typeof G
>"A" : string
2015-04-16 03:12:39 +02:00
var g = o[G.A];
2015-04-17 08:25:52 +02:00
>g : boolean
2015-04-16 03:12:39 +02:00
>o[G.A] : boolean
2015-04-17 08:25:52 +02:00
>o : { [idx: number]: boolean; }
>G.A : G
>G : typeof G
>A : G
2015-04-16 03:12:39 +02:00
class C {
2015-04-17 08:25:52 +02:00
>C : C
2015-04-16 03:12:39 +02:00
[G.A]() { }
2015-04-17 08:25:52 +02:00
>G.A : G
>G : typeof G
>A : G
2015-04-16 03:12:39 +02:00
get [G.B]() {
2015-04-17 08:25:52 +02:00
>G.B : G
>G : typeof G
>B : G
2015-04-16 03:12:39 +02:00
return true;
>true : boolean
}
set [G.B](x: number) { }
2015-04-17 08:25:52 +02:00
>G.B : G
>G : typeof G
>B : G
>x : number
2015-04-16 03:12:39 +02:00
}