mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Add test for class from external module is used in union
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
//// [tests/cases/compiler/metadataOfClassFromAlias.ts] ////
|
||||
|
||||
//// [auxiliry.ts]
|
||||
|
||||
export class SomeClass {
|
||||
field: string;
|
||||
}
|
||||
|
||||
//// [test.ts]
|
||||
import { SomeClass } from './auxiliry';
|
||||
function annotation(): PropertyDecorator {
|
||||
return (target: any): void => { };
|
||||
}
|
||||
export class ClassA {
|
||||
@annotation() array: SomeClass | null;
|
||||
}
|
||||
|
||||
//// [auxiliry.js]
|
||||
"use strict";
|
||||
var SomeClass = (function () {
|
||||
function SomeClass() {
|
||||
}
|
||||
return SomeClass;
|
||||
}());
|
||||
exports.SomeClass = SomeClass;
|
||||
//// [test.js]
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
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;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
function annotation() {
|
||||
return function (target) { };
|
||||
}
|
||||
var ClassA = (function () {
|
||||
function ClassA() {
|
||||
}
|
||||
return ClassA;
|
||||
}());
|
||||
__decorate([
|
||||
annotation(),
|
||||
__metadata("design:type", auxiliry_1.SomeClass)
|
||||
], ClassA.prototype, "array", void 0);
|
||||
exports.ClassA = ClassA;
|
||||
@@ -0,0 +1,28 @@
|
||||
=== tests/cases/compiler/auxiliry.ts ===
|
||||
|
||||
export class SomeClass {
|
||||
>SomeClass : Symbol(SomeClass, Decl(auxiliry.ts, 0, 0))
|
||||
|
||||
field: string;
|
||||
>field : Symbol(SomeClass.field, Decl(auxiliry.ts, 1, 24))
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/test.ts ===
|
||||
import { SomeClass } from './auxiliry';
|
||||
>SomeClass : Symbol(SomeClass, Decl(test.ts, 0, 8))
|
||||
|
||||
function annotation(): PropertyDecorator {
|
||||
>annotation : Symbol(annotation, Decl(test.ts, 0, 39))
|
||||
>PropertyDecorator : Symbol(PropertyDecorator, Decl(lib.d.ts, --, --))
|
||||
|
||||
return (target: any): void => { };
|
||||
>target : Symbol(target, Decl(test.ts, 2, 12))
|
||||
}
|
||||
export class ClassA {
|
||||
>ClassA : Symbol(ClassA, Decl(test.ts, 3, 1))
|
||||
|
||||
@annotation() array: SomeClass | null;
|
||||
>annotation : Symbol(annotation, Decl(test.ts, 0, 39))
|
||||
>array : Symbol(ClassA.array, Decl(test.ts, 4, 21))
|
||||
>SomeClass : Symbol(SomeClass, Decl(test.ts, 0, 8))
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
=== tests/cases/compiler/auxiliry.ts ===
|
||||
|
||||
export class SomeClass {
|
||||
>SomeClass : SomeClass
|
||||
|
||||
field: string;
|
||||
>field : string
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/test.ts ===
|
||||
import { SomeClass } from './auxiliry';
|
||||
>SomeClass : typeof SomeClass
|
||||
|
||||
function annotation(): PropertyDecorator {
|
||||
>annotation : () => PropertyDecorator
|
||||
>PropertyDecorator : PropertyDecorator
|
||||
|
||||
return (target: any): void => { };
|
||||
>(target: any): void => { } : (target: any) => void
|
||||
>target : any
|
||||
}
|
||||
export class ClassA {
|
||||
>ClassA : ClassA
|
||||
|
||||
@annotation() array: SomeClass | null;
|
||||
>annotation() : PropertyDecorator
|
||||
>annotation : () => PropertyDecorator
|
||||
>array : SomeClass
|
||||
>SomeClass : SomeClass
|
||||
>null : null
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// @experimentalDecorators: true
|
||||
// @emitDecoratorMetadata: true
|
||||
// @target: es5
|
||||
// @module: commonjs
|
||||
|
||||
// @filename: auxiliry.ts
|
||||
export class SomeClass {
|
||||
field: string;
|
||||
}
|
||||
|
||||
//@filename: test.ts
|
||||
import { SomeClass } from './auxiliry';
|
||||
function annotation(): PropertyDecorator {
|
||||
return (target: any): void => { };
|
||||
}
|
||||
export class ClassA {
|
||||
@annotation() array: SomeClass | null;
|
||||
}
|
||||
Reference in New Issue
Block a user