Skip to content

Commit 8e4efb6

Browse files
committed
Added test case for enums
1 parent 32de4d7 commit 8e4efb6

File tree

4 files changed

+174
-0
lines changed

4 files changed

+174
-0
lines changed

tests/baselines/reference/metadataOfUnion.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,27 @@ class B {
1313

1414
@PropDeco
1515
z: "foo" | boolean;
16+
}
17+
18+
enum E {
19+
A,
20+
B,
21+
C,
22+
D
23+
}
24+
25+
class D {
26+
@PropDeco
27+
a: E.A;
28+
29+
@PropDeco
30+
b: E.B | E.C;
31+
32+
@PropDeco
33+
c: E;
34+
35+
@PropDeco
36+
d: E | number;
1637
}
1738

1839
//// [metadataOfUnion.js]
@@ -48,3 +69,31 @@ __decorate([
4869
PropDeco,
4970
__metadata("design:type", Object)
5071
], B.prototype, "z");
72+
var E;
73+
(function (E) {
74+
E[E["A"] = 0] = "A";
75+
E[E["B"] = 1] = "B";
76+
E[E["C"] = 2] = "C";
77+
E[E["D"] = 3] = "D";
78+
})(E || (E = {}));
79+
var D = (function () {
80+
function D() {
81+
}
82+
return D;
83+
}());
84+
__decorate([
85+
PropDeco,
86+
__metadata("design:type", Number)
87+
], D.prototype, "a");
88+
__decorate([
89+
PropDeco,
90+
__metadata("design:type", Number)
91+
], D.prototype, "b");
92+
__decorate([
93+
PropDeco,
94+
__metadata("design:type", Number)
95+
], D.prototype, "c");
96+
__decorate([
97+
PropDeco,
98+
__metadata("design:type", Number)
99+
], D.prototype, "d");

tests/baselines/reference/metadataOfUnion.symbols

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,55 @@ class B {
3131
z: "foo" | boolean;
3232
>z : Symbol(B.z, Decl(metadataOfUnion.ts, 10, 22))
3333
}
34+
35+
enum E {
36+
>E : Symbol(E, Decl(metadataOfUnion.ts, 14, 1))
37+
38+
A,
39+
>A : Symbol(E.A, Decl(metadataOfUnion.ts, 16, 8))
40+
41+
B,
42+
>B : Symbol(E.B, Decl(metadataOfUnion.ts, 17, 6))
43+
44+
C,
45+
>C : Symbol(E.C, Decl(metadataOfUnion.ts, 18, 6))
46+
47+
D
48+
>D : Symbol(E.D, Decl(metadataOfUnion.ts, 19, 6))
49+
}
50+
51+
class D {
52+
>D : Symbol(D, Decl(metadataOfUnion.ts, 21, 1))
53+
54+
@PropDeco
55+
>PropDeco : Symbol(PropDeco, Decl(metadataOfUnion.ts, 0, 0))
56+
57+
a: E.A;
58+
>a : Symbol(D.a, Decl(metadataOfUnion.ts, 23, 9))
59+
>E : Symbol(E, Decl(metadataOfUnion.ts, 14, 1))
60+
>A : Symbol(E.A, Decl(metadataOfUnion.ts, 16, 8))
61+
62+
@PropDeco
63+
>PropDeco : Symbol(PropDeco, Decl(metadataOfUnion.ts, 0, 0))
64+
65+
b: E.B | E.C;
66+
>b : Symbol(D.b, Decl(metadataOfUnion.ts, 25, 11))
67+
>E : Symbol(E, Decl(metadataOfUnion.ts, 14, 1))
68+
>B : Symbol(E.B, Decl(metadataOfUnion.ts, 17, 6))
69+
>E : Symbol(E, Decl(metadataOfUnion.ts, 14, 1))
70+
>C : Symbol(E.C, Decl(metadataOfUnion.ts, 18, 6))
71+
72+
@PropDeco
73+
>PropDeco : Symbol(PropDeco, Decl(metadataOfUnion.ts, 0, 0))
74+
75+
c: E;
76+
>c : Symbol(D.c, Decl(metadataOfUnion.ts, 28, 17))
77+
>E : Symbol(E, Decl(metadataOfUnion.ts, 14, 1))
78+
79+
@PropDeco
80+
>PropDeco : Symbol(PropDeco, Decl(metadataOfUnion.ts, 0, 0))
81+
82+
d: E | number;
83+
>d : Symbol(D.d, Decl(metadataOfUnion.ts, 31, 9))
84+
>E : Symbol(E, Decl(metadataOfUnion.ts, 14, 1))
85+
}

tests/baselines/reference/metadataOfUnion.types

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,55 @@ class B {
3232
z: "foo" | boolean;
3333
>z : boolean | "foo"
3434
}
35+
36+
enum E {
37+
>E : E
38+
39+
A,
40+
>A : E.A
41+
42+
B,
43+
>B : E.B
44+
45+
C,
46+
>C : E.C
47+
48+
D
49+
>D : E.D
50+
}
51+
52+
class D {
53+
>D : D
54+
55+
@PropDeco
56+
>PropDeco : (target: Object, propKey: string | symbol) => void
57+
58+
a: E.A;
59+
>a : E.A
60+
>E : any
61+
>A : E.A
62+
63+
@PropDeco
64+
>PropDeco : (target: Object, propKey: string | symbol) => void
65+
66+
b: E.B | E.C;
67+
>b : E.B | E.C
68+
>E : any
69+
>B : E.B
70+
>E : any
71+
>C : E.C
72+
73+
@PropDeco
74+
>PropDeco : (target: Object, propKey: string | symbol) => void
75+
76+
c: E;
77+
>c : E
78+
>E : E
79+
80+
@PropDeco
81+
>PropDeco : (target: Object, propKey: string | symbol) => void
82+
83+
d: E | number;
84+
>d : number | E
85+
>E : E
86+
}

tests/cases/compiler/metadataOfUnion.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,25 @@ class B {
1414

1515
@PropDeco
1616
z: "foo" | boolean;
17+
}
18+
19+
enum E {
20+
A,
21+
B,
22+
C,
23+
D
24+
}
25+
26+
class D {
27+
@PropDeco
28+
a: E.A;
29+
30+
@PropDeco
31+
b: E.B | E.C;
32+
33+
@PropDeco
34+
c: E;
35+
36+
@PropDeco
37+
d: E | number;
1738
}

0 commit comments

Comments
 (0)