Skip to content

Commit b345a78

Browse files
committed
Add test for class from external module is used in union
1 parent 65ef51d commit b345a78

File tree

4 files changed

+126
-0
lines changed

4 files changed

+126
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
//// [tests/cases/compiler/metadataOfClassFromAlias.ts] ////
2+
3+
//// [auxiliry.ts]
4+
5+
export class SomeClass {
6+
field: string;
7+
}
8+
9+
//// [test.ts]
10+
import { SomeClass } from './auxiliry';
11+
function annotation(): PropertyDecorator {
12+
return (target: any): void => { };
13+
}
14+
export class ClassA {
15+
@annotation() array: SomeClass | null;
16+
}
17+
18+
//// [auxiliry.js]
19+
"use strict";
20+
var SomeClass = (function () {
21+
function SomeClass() {
22+
}
23+
return SomeClass;
24+
}());
25+
exports.SomeClass = SomeClass;
26+
//// [test.js]
27+
"use strict";
28+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
29+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
30+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
31+
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;
32+
return c > 3 && r && Object.defineProperty(target, key, r), r;
33+
};
34+
var __metadata = (this && this.__metadata) || function (k, v) {
35+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
36+
};
37+
function annotation() {
38+
return function (target) { };
39+
}
40+
var ClassA = (function () {
41+
function ClassA() {
42+
}
43+
return ClassA;
44+
}());
45+
__decorate([
46+
annotation(),
47+
__metadata("design:type", auxiliry_1.SomeClass)
48+
], ClassA.prototype, "array", void 0);
49+
exports.ClassA = ClassA;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
=== tests/cases/compiler/auxiliry.ts ===
2+
3+
export class SomeClass {
4+
>SomeClass : Symbol(SomeClass, Decl(auxiliry.ts, 0, 0))
5+
6+
field: string;
7+
>field : Symbol(SomeClass.field, Decl(auxiliry.ts, 1, 24))
8+
}
9+
10+
=== tests/cases/compiler/test.ts ===
11+
import { SomeClass } from './auxiliry';
12+
>SomeClass : Symbol(SomeClass, Decl(test.ts, 0, 8))
13+
14+
function annotation(): PropertyDecorator {
15+
>annotation : Symbol(annotation, Decl(test.ts, 0, 39))
16+
>PropertyDecorator : Symbol(PropertyDecorator, Decl(lib.d.ts, --, --))
17+
18+
return (target: any): void => { };
19+
>target : Symbol(target, Decl(test.ts, 2, 12))
20+
}
21+
export class ClassA {
22+
>ClassA : Symbol(ClassA, Decl(test.ts, 3, 1))
23+
24+
@annotation() array: SomeClass | null;
25+
>annotation : Symbol(annotation, Decl(test.ts, 0, 39))
26+
>array : Symbol(ClassA.array, Decl(test.ts, 4, 21))
27+
>SomeClass : Symbol(SomeClass, Decl(test.ts, 0, 8))
28+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
=== tests/cases/compiler/auxiliry.ts ===
2+
3+
export class SomeClass {
4+
>SomeClass : SomeClass
5+
6+
field: string;
7+
>field : string
8+
}
9+
10+
=== tests/cases/compiler/test.ts ===
11+
import { SomeClass } from './auxiliry';
12+
>SomeClass : typeof SomeClass
13+
14+
function annotation(): PropertyDecorator {
15+
>annotation : () => PropertyDecorator
16+
>PropertyDecorator : PropertyDecorator
17+
18+
return (target: any): void => { };
19+
>(target: any): void => { } : (target: any) => void
20+
>target : any
21+
}
22+
export class ClassA {
23+
>ClassA : ClassA
24+
25+
@annotation() array: SomeClass | null;
26+
>annotation() : PropertyDecorator
27+
>annotation : () => PropertyDecorator
28+
>array : SomeClass
29+
>SomeClass : SomeClass
30+
>null : null
31+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// @experimentalDecorators: true
2+
// @emitDecoratorMetadata: true
3+
// @target: es5
4+
// @module: commonjs
5+
6+
// @filename: auxiliry.ts
7+
export class SomeClass {
8+
field: string;
9+
}
10+
11+
//@filename: test.ts
12+
import { SomeClass } from './auxiliry';
13+
function annotation(): PropertyDecorator {
14+
return (target: any): void => { };
15+
}
16+
export class ClassA {
17+
@annotation() array: SomeClass | null;
18+
}

0 commit comments

Comments
 (0)