Skip to content

Commit 32de4d7

Browse files
committed
Another test case
1 parent 40c2a53 commit 32de4d7

File tree

4 files changed

+134
-0
lines changed

4 files changed

+134
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
//// [metadataOfUnion.ts]
2+
function PropDeco(target: Object, propKey: string | symbol) { }
3+
4+
class A {
5+
}
6+
7+
class B {
8+
@PropDeco
9+
x: "foo" | A;
10+
11+
@PropDeco
12+
y: true | boolean;
13+
14+
@PropDeco
15+
z: "foo" | boolean;
16+
}
17+
18+
//// [metadataOfUnion.js]
19+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
20+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
21+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
22+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
23+
return c > 3 && r && Object.defineProperty(target, key, r), r;
24+
};
25+
var __metadata = (this && this.__metadata) || function (k, v) {
26+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
27+
};
28+
function PropDeco(target, propKey) { }
29+
var A = (function () {
30+
function A() {
31+
}
32+
return A;
33+
}());
34+
var B = (function () {
35+
function B() {
36+
}
37+
return B;
38+
}());
39+
__decorate([
40+
PropDeco,
41+
__metadata("design:type", Object)
42+
], B.prototype, "x");
43+
__decorate([
44+
PropDeco,
45+
__metadata("design:type", Boolean)
46+
], B.prototype, "y");
47+
__decorate([
48+
PropDeco,
49+
__metadata("design:type", Object)
50+
], B.prototype, "z");
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
=== tests/cases/compiler/metadataOfUnion.ts ===
2+
function PropDeco(target: Object, propKey: string | symbol) { }
3+
>PropDeco : Symbol(PropDeco, Decl(metadataOfUnion.ts, 0, 0))
4+
>target : Symbol(target, Decl(metadataOfUnion.ts, 0, 18))
5+
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
6+
>propKey : Symbol(propKey, Decl(metadataOfUnion.ts, 0, 33))
7+
8+
class A {
9+
>A : Symbol(A, Decl(metadataOfUnion.ts, 0, 63))
10+
}
11+
12+
class B {
13+
>B : Symbol(B, Decl(metadataOfUnion.ts, 3, 1))
14+
15+
@PropDeco
16+
>PropDeco : Symbol(PropDeco, Decl(metadataOfUnion.ts, 0, 0))
17+
18+
x: "foo" | A;
19+
>x : Symbol(B.x, Decl(metadataOfUnion.ts, 5, 9))
20+
>A : Symbol(A, Decl(metadataOfUnion.ts, 0, 63))
21+
22+
@PropDeco
23+
>PropDeco : Symbol(PropDeco, Decl(metadataOfUnion.ts, 0, 0))
24+
25+
y: true | boolean;
26+
>y : Symbol(B.y, Decl(metadataOfUnion.ts, 7, 17))
27+
28+
@PropDeco
29+
>PropDeco : Symbol(PropDeco, Decl(metadataOfUnion.ts, 0, 0))
30+
31+
z: "foo" | boolean;
32+
>z : Symbol(B.z, Decl(metadataOfUnion.ts, 10, 22))
33+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
=== tests/cases/compiler/metadataOfUnion.ts ===
2+
function PropDeco(target: Object, propKey: string | symbol) { }
3+
>PropDeco : (target: Object, propKey: string | symbol) => void
4+
>target : Object
5+
>Object : Object
6+
>propKey : string | symbol
7+
8+
class A {
9+
>A : A
10+
}
11+
12+
class B {
13+
>B : B
14+
15+
@PropDeco
16+
>PropDeco : (target: Object, propKey: string | symbol) => void
17+
18+
x: "foo" | A;
19+
>x : A | "foo"
20+
>A : A
21+
22+
@PropDeco
23+
>PropDeco : (target: Object, propKey: string | symbol) => void
24+
25+
y: true | boolean;
26+
>y : boolean
27+
>true : true
28+
29+
@PropDeco
30+
>PropDeco : (target: Object, propKey: string | symbol) => void
31+
32+
z: "foo" | boolean;
33+
>z : boolean | "foo"
34+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// @experimentalDecorators: true
2+
// @emitDecoratorMetadata: true
3+
function PropDeco(target: Object, propKey: string | symbol) { }
4+
5+
class A {
6+
}
7+
8+
class B {
9+
@PropDeco
10+
x: "foo" | A;
11+
12+
@PropDeco
13+
y: true | boolean;
14+
15+
@PropDeco
16+
z: "foo" | boolean;
17+
}

0 commit comments

Comments
 (0)