Skip to content

Commit c40234f

Browse files
committed
Adding test for emit of metadata for string literal union
1 parent a31415d commit c40234f

File tree

4 files changed

+68
-0
lines changed

4 files changed

+68
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//// [metadataOfStringLiteral.ts]
2+
function PropDeco(target: Object, propKey: string | symbol) { }
3+
4+
class Foo {
5+
@PropDeco
6+
public foo: "foo" | "bar";
7+
}
8+
9+
//// [metadataOfStringLiteral.js]
10+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
11+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
12+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
13+
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;
14+
return c > 3 && r && Object.defineProperty(target, key, r), r;
15+
};
16+
var __metadata = (this && this.__metadata) || function (k, v) {
17+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
18+
};
19+
function PropDeco(target, propKey) { }
20+
var Foo = (function () {
21+
function Foo() {
22+
}
23+
return Foo;
24+
}());
25+
__decorate([
26+
PropDeco,
27+
__metadata("design:type", Object)
28+
], Foo.prototype, "foo");
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
=== tests/cases/compiler/metadataOfStringLiteral.ts ===
2+
function PropDeco(target: Object, propKey: string | symbol) { }
3+
>PropDeco : Symbol(PropDeco, Decl(metadataOfStringLiteral.ts, 0, 0))
4+
>target : Symbol(target, Decl(metadataOfStringLiteral.ts, 0, 18))
5+
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
6+
>propKey : Symbol(propKey, Decl(metadataOfStringLiteral.ts, 0, 33))
7+
8+
class Foo {
9+
>Foo : Symbol(Foo, Decl(metadataOfStringLiteral.ts, 0, 63))
10+
11+
@PropDeco
12+
>PropDeco : Symbol(PropDeco, Decl(metadataOfStringLiteral.ts, 0, 0))
13+
14+
public foo: "foo" | "bar";
15+
>foo : Symbol(Foo.foo, Decl(metadataOfStringLiteral.ts, 2, 11))
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
=== tests/cases/compiler/metadataOfStringLiteral.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 Foo {
9+
>Foo : Foo
10+
11+
@PropDeco
12+
>PropDeco : (target: Object, propKey: string | symbol) => void
13+
14+
public foo: "foo" | "bar";
15+
>foo : "foo" | "bar"
16+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// @experimentalDecorators: true
2+
// @emitDecoratorMetadata: true
3+
function PropDeco(target: Object, propKey: string | symbol) { }
4+
5+
class Foo {
6+
@PropDeco
7+
public foo: "foo" | "bar";
8+
}

0 commit comments

Comments
 (0)