Merge pull request #4386 from Microsoft/importDeclarationAndDecorator
Resolve the decorator type as type and check if the symbol has value.
This commit is contained in:
commit
b8c8dbcf4c
|
@ -11384,12 +11384,19 @@ namespace ts {
|
||||||
// serialize the type metadata.
|
// serialize the type metadata.
|
||||||
if (node && node.kind === SyntaxKind.TypeReference) {
|
if (node && node.kind === SyntaxKind.TypeReference) {
|
||||||
let root = getFirstIdentifier((<TypeReferenceNode>node).typeName);
|
let root = getFirstIdentifier((<TypeReferenceNode>node).typeName);
|
||||||
let rootSymbol = resolveName(root, root.text, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined);
|
let meaning = root.parent.kind === SyntaxKind.TypeReference ? SymbolFlags.Type : SymbolFlags.Namespace;
|
||||||
if (rootSymbol && rootSymbol.flags & SymbolFlags.Alias && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) {
|
// Resolve type so we know which symbol is referenced
|
||||||
|
let rootSymbol = resolveName(root, root.text, meaning | SymbolFlags.Alias, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined);
|
||||||
|
// Resolved symbol is alias
|
||||||
|
if (rootSymbol && rootSymbol.flags & SymbolFlags.Alias) {
|
||||||
|
let aliasTarget = resolveAlias(rootSymbol);
|
||||||
|
// If alias has value symbol - mark alias as referenced
|
||||||
|
if (aliasTarget.flags & SymbolFlags.Value && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) {
|
||||||
markAliasSymbolAsReferenced(rootSymbol);
|
markAliasSymbolAsReferenced(rootSymbol);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks the type annotation of an accessor declaration or property declaration as
|
* Checks the type annotation of an accessor declaration or property declaration as
|
||||||
|
@ -14402,6 +14409,10 @@ namespace ts {
|
||||||
|
|
||||||
// Resolve the symbol as a type so that we can provide a more useful hint for the type serializer.
|
// Resolve the symbol as a type so that we can provide a more useful hint for the type serializer.
|
||||||
let typeSymbol = resolveEntityName(typeName, SymbolFlags.Type, /*ignoreErrors*/ true);
|
let typeSymbol = resolveEntityName(typeName, SymbolFlags.Type, /*ignoreErrors*/ true);
|
||||||
|
// We might not be able to resolve type symbol so use unknown type in that case (eg error case)
|
||||||
|
if (!typeSymbol) {
|
||||||
|
return TypeReferenceSerializationKind.ObjectType;
|
||||||
|
}
|
||||||
let type = getDeclaredTypeOfSymbol(typeSymbol);
|
let type = getDeclaredTypeOfSymbol(typeSymbol);
|
||||||
if (type === unknownType) {
|
if (type === unknownType) {
|
||||||
return TypeReferenceSerializationKind.Unknown;
|
return TypeReferenceSerializationKind.Unknown;
|
||||||
|
|
|
@ -1552,6 +1552,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||||
else if (isNameOfNestedRedeclaration(node)) {
|
else if (isNameOfNestedRedeclaration(node)) {
|
||||||
write(getGeneratedNameForNode(node));
|
write(getGeneratedNameForNode(node));
|
||||||
}
|
}
|
||||||
|
else if (nodeIsSynthesized(node)) {
|
||||||
|
write(node.text);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
writeTextOfNode(currentSourceFile, node);
|
writeTextOfNode(currentSourceFile, node);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
||||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||||
};
|
};
|
||||||
|
var service_1 = require("./service");
|
||||||
var MyComponent = (function () {
|
var MyComponent = (function () {
|
||||||
function MyComponent(Service) {
|
function MyComponent(Service) {
|
||||||
this.Service = Service;
|
this.Service = Service;
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision.ts] ////
|
||||||
|
|
||||||
|
//// [db.ts]
|
||||||
|
export class db {
|
||||||
|
public doSomething() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//// [service.ts]
|
||||||
|
import {db} from './db';
|
||||||
|
function someDecorator(target) {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
@someDecorator
|
||||||
|
class MyClass {
|
||||||
|
db: db;
|
||||||
|
|
||||||
|
constructor(db: db) {
|
||||||
|
this.db = db;
|
||||||
|
this.db.doSomething();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export {MyClass};
|
||||||
|
|
||||||
|
|
||||||
|
//// [db.js]
|
||||||
|
var db = (function () {
|
||||||
|
function db() {
|
||||||
|
}
|
||||||
|
db.prototype.doSomething = function () {
|
||||||
|
};
|
||||||
|
return db;
|
||||||
|
})();
|
||||||
|
exports.db = db;
|
||||||
|
//// [service.js]
|
||||||
|
var db_1 = require('./db');
|
||||||
|
function someDecorator(target) {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
var MyClass = (function () {
|
||||||
|
function MyClass(db) {
|
||||||
|
this.db = db;
|
||||||
|
this.db.doSomething();
|
||||||
|
}
|
||||||
|
MyClass = __decorate([
|
||||||
|
someDecorator,
|
||||||
|
__metadata('design:paramtypes', [db_1.db])
|
||||||
|
], MyClass);
|
||||||
|
return MyClass;
|
||||||
|
})();
|
||||||
|
exports.MyClass = MyClass;
|
|
@ -0,0 +1,51 @@
|
||||||
|
=== tests/cases/compiler/db.ts ===
|
||||||
|
export class db {
|
||||||
|
>db : Symbol(db, Decl(db.ts, 0, 0))
|
||||||
|
|
||||||
|
public doSomething() {
|
||||||
|
>doSomething : Symbol(doSomething, Decl(db.ts, 0, 17))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
=== tests/cases/compiler/service.ts ===
|
||||||
|
import {db} from './db';
|
||||||
|
>db : Symbol(db, Decl(service.ts, 0, 8))
|
||||||
|
|
||||||
|
function someDecorator(target) {
|
||||||
|
>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 24))
|
||||||
|
>target : Symbol(target, Decl(service.ts, 1, 23))
|
||||||
|
|
||||||
|
return target;
|
||||||
|
>target : Symbol(target, Decl(service.ts, 1, 23))
|
||||||
|
}
|
||||||
|
@someDecorator
|
||||||
|
>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 24))
|
||||||
|
|
||||||
|
class MyClass {
|
||||||
|
>MyClass : Symbol(MyClass, Decl(service.ts, 3, 1))
|
||||||
|
|
||||||
|
db: db;
|
||||||
|
>db : Symbol(db, Decl(service.ts, 5, 15))
|
||||||
|
>db : Symbol(db, Decl(service.ts, 0, 8))
|
||||||
|
|
||||||
|
constructor(db: db) {
|
||||||
|
>db : Symbol(db, Decl(service.ts, 8, 16))
|
||||||
|
>db : Symbol(db, Decl(service.ts, 0, 8))
|
||||||
|
|
||||||
|
this.db = db;
|
||||||
|
>this.db : Symbol(db, Decl(service.ts, 5, 15))
|
||||||
|
>this : Symbol(MyClass, Decl(service.ts, 3, 1))
|
||||||
|
>db : Symbol(db, Decl(service.ts, 5, 15))
|
||||||
|
>db : Symbol(db, Decl(service.ts, 8, 16))
|
||||||
|
|
||||||
|
this.db.doSomething();
|
||||||
|
>this.db.doSomething : Symbol(db.doSomething, Decl(db.ts, 0, 17))
|
||||||
|
>this.db : Symbol(db, Decl(service.ts, 5, 15))
|
||||||
|
>this : Symbol(MyClass, Decl(service.ts, 3, 1))
|
||||||
|
>db : Symbol(db, Decl(service.ts, 5, 15))
|
||||||
|
>doSomething : Symbol(db.doSomething, Decl(db.ts, 0, 17))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export {MyClass};
|
||||||
|
>MyClass : Symbol(MyClass, Decl(service.ts, 13, 8))
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
=== tests/cases/compiler/db.ts ===
|
||||||
|
export class db {
|
||||||
|
>db : db
|
||||||
|
|
||||||
|
public doSomething() {
|
||||||
|
>doSomething : () => void
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
=== tests/cases/compiler/service.ts ===
|
||||||
|
import {db} from './db';
|
||||||
|
>db : typeof db
|
||||||
|
|
||||||
|
function someDecorator(target) {
|
||||||
|
>someDecorator : (target: any) => any
|
||||||
|
>target : any
|
||||||
|
|
||||||
|
return target;
|
||||||
|
>target : any
|
||||||
|
}
|
||||||
|
@someDecorator
|
||||||
|
>someDecorator : (target: any) => any
|
||||||
|
|
||||||
|
class MyClass {
|
||||||
|
>MyClass : MyClass
|
||||||
|
|
||||||
|
db: db;
|
||||||
|
>db : db
|
||||||
|
>db : db
|
||||||
|
|
||||||
|
constructor(db: db) {
|
||||||
|
>db : db
|
||||||
|
>db : db
|
||||||
|
|
||||||
|
this.db = db;
|
||||||
|
>this.db = db : db
|
||||||
|
>this.db : db
|
||||||
|
>this : MyClass
|
||||||
|
>db : db
|
||||||
|
>db : db
|
||||||
|
|
||||||
|
this.db.doSomething();
|
||||||
|
>this.db.doSomething() : void
|
||||||
|
>this.db.doSomething : () => void
|
||||||
|
>this.db : db
|
||||||
|
>this : MyClass
|
||||||
|
>db : db
|
||||||
|
>doSomething : () => void
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export {MyClass};
|
||||||
|
>MyClass : typeof MyClass
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision2.ts] ////
|
||||||
|
|
||||||
|
//// [db.ts]
|
||||||
|
export class db {
|
||||||
|
public doSomething() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//// [service.ts]
|
||||||
|
import {db as Database} from './db';
|
||||||
|
function someDecorator(target) {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
@someDecorator
|
||||||
|
class MyClass {
|
||||||
|
db: Database;
|
||||||
|
|
||||||
|
constructor(db: Database) { // no collision
|
||||||
|
this.db = db;
|
||||||
|
this.db.doSomething();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export {MyClass};
|
||||||
|
|
||||||
|
|
||||||
|
//// [db.js]
|
||||||
|
var db = (function () {
|
||||||
|
function db() {
|
||||||
|
}
|
||||||
|
db.prototype.doSomething = function () {
|
||||||
|
};
|
||||||
|
return db;
|
||||||
|
})();
|
||||||
|
exports.db = db;
|
||||||
|
//// [service.js]
|
||||||
|
var db_1 = require('./db');
|
||||||
|
function someDecorator(target) {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
var MyClass = (function () {
|
||||||
|
function MyClass(db) {
|
||||||
|
this.db = db;
|
||||||
|
this.db.doSomething();
|
||||||
|
}
|
||||||
|
MyClass = __decorate([
|
||||||
|
someDecorator,
|
||||||
|
__metadata('design:paramtypes', [db_1.db])
|
||||||
|
], MyClass);
|
||||||
|
return MyClass;
|
||||||
|
})();
|
||||||
|
exports.MyClass = MyClass;
|
|
@ -0,0 +1,52 @@
|
||||||
|
=== tests/cases/compiler/db.ts ===
|
||||||
|
export class db {
|
||||||
|
>db : Symbol(db, Decl(db.ts, 0, 0))
|
||||||
|
|
||||||
|
public doSomething() {
|
||||||
|
>doSomething : Symbol(doSomething, Decl(db.ts, 0, 17))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
=== tests/cases/compiler/service.ts ===
|
||||||
|
import {db as Database} from './db';
|
||||||
|
>db : Symbol(Database, Decl(service.ts, 0, 8))
|
||||||
|
>Database : Symbol(Database, Decl(service.ts, 0, 8))
|
||||||
|
|
||||||
|
function someDecorator(target) {
|
||||||
|
>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 36))
|
||||||
|
>target : Symbol(target, Decl(service.ts, 1, 23))
|
||||||
|
|
||||||
|
return target;
|
||||||
|
>target : Symbol(target, Decl(service.ts, 1, 23))
|
||||||
|
}
|
||||||
|
@someDecorator
|
||||||
|
>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 36))
|
||||||
|
|
||||||
|
class MyClass {
|
||||||
|
>MyClass : Symbol(MyClass, Decl(service.ts, 3, 1))
|
||||||
|
|
||||||
|
db: Database;
|
||||||
|
>db : Symbol(db, Decl(service.ts, 5, 15))
|
||||||
|
>Database : Symbol(Database, Decl(service.ts, 0, 8))
|
||||||
|
|
||||||
|
constructor(db: Database) { // no collision
|
||||||
|
>db : Symbol(db, Decl(service.ts, 8, 16))
|
||||||
|
>Database : Symbol(Database, Decl(service.ts, 0, 8))
|
||||||
|
|
||||||
|
this.db = db;
|
||||||
|
>this.db : Symbol(db, Decl(service.ts, 5, 15))
|
||||||
|
>this : Symbol(MyClass, Decl(service.ts, 3, 1))
|
||||||
|
>db : Symbol(db, Decl(service.ts, 5, 15))
|
||||||
|
>db : Symbol(db, Decl(service.ts, 8, 16))
|
||||||
|
|
||||||
|
this.db.doSomething();
|
||||||
|
>this.db.doSomething : Symbol(Database.doSomething, Decl(db.ts, 0, 17))
|
||||||
|
>this.db : Symbol(db, Decl(service.ts, 5, 15))
|
||||||
|
>this : Symbol(MyClass, Decl(service.ts, 3, 1))
|
||||||
|
>db : Symbol(db, Decl(service.ts, 5, 15))
|
||||||
|
>doSomething : Symbol(Database.doSomething, Decl(db.ts, 0, 17))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export {MyClass};
|
||||||
|
>MyClass : Symbol(MyClass, Decl(service.ts, 13, 8))
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
=== tests/cases/compiler/db.ts ===
|
||||||
|
export class db {
|
||||||
|
>db : db
|
||||||
|
|
||||||
|
public doSomething() {
|
||||||
|
>doSomething : () => void
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
=== tests/cases/compiler/service.ts ===
|
||||||
|
import {db as Database} from './db';
|
||||||
|
>db : typeof Database
|
||||||
|
>Database : typeof Database
|
||||||
|
|
||||||
|
function someDecorator(target) {
|
||||||
|
>someDecorator : (target: any) => any
|
||||||
|
>target : any
|
||||||
|
|
||||||
|
return target;
|
||||||
|
>target : any
|
||||||
|
}
|
||||||
|
@someDecorator
|
||||||
|
>someDecorator : (target: any) => any
|
||||||
|
|
||||||
|
class MyClass {
|
||||||
|
>MyClass : MyClass
|
||||||
|
|
||||||
|
db: Database;
|
||||||
|
>db : Database
|
||||||
|
>Database : Database
|
||||||
|
|
||||||
|
constructor(db: Database) { // no collision
|
||||||
|
>db : Database
|
||||||
|
>Database : Database
|
||||||
|
|
||||||
|
this.db = db;
|
||||||
|
>this.db = db : Database
|
||||||
|
>this.db : Database
|
||||||
|
>this : MyClass
|
||||||
|
>db : Database
|
||||||
|
>db : Database
|
||||||
|
|
||||||
|
this.db.doSomething();
|
||||||
|
>this.db.doSomething() : void
|
||||||
|
>this.db.doSomething : () => void
|
||||||
|
>this.db : Database
|
||||||
|
>this : MyClass
|
||||||
|
>db : Database
|
||||||
|
>doSomething : () => void
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export {MyClass};
|
||||||
|
>MyClass : typeof MyClass
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision3.ts] ////
|
||||||
|
|
||||||
|
//// [db.ts]
|
||||||
|
export class db {
|
||||||
|
public doSomething() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//// [service.ts]
|
||||||
|
import db = require('./db');
|
||||||
|
function someDecorator(target) {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
@someDecorator
|
||||||
|
class MyClass {
|
||||||
|
db: db.db;
|
||||||
|
|
||||||
|
constructor(db: db.db) { // collision with namespace of external module db
|
||||||
|
this.db = db;
|
||||||
|
this.db.doSomething();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export {MyClass};
|
||||||
|
|
||||||
|
|
||||||
|
//// [db.js]
|
||||||
|
var db = (function () {
|
||||||
|
function db() {
|
||||||
|
}
|
||||||
|
db.prototype.doSomething = function () {
|
||||||
|
};
|
||||||
|
return db;
|
||||||
|
})();
|
||||||
|
exports.db = db;
|
||||||
|
//// [service.js]
|
||||||
|
var db = require('./db');
|
||||||
|
function someDecorator(target) {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
var MyClass = (function () {
|
||||||
|
function MyClass(db) {
|
||||||
|
this.db = db;
|
||||||
|
this.db.doSomething();
|
||||||
|
}
|
||||||
|
MyClass = __decorate([
|
||||||
|
someDecorator,
|
||||||
|
__metadata('design:paramtypes', [db.db])
|
||||||
|
], MyClass);
|
||||||
|
return MyClass;
|
||||||
|
})();
|
||||||
|
exports.MyClass = MyClass;
|
|
@ -0,0 +1,53 @@
|
||||||
|
=== tests/cases/compiler/service.ts ===
|
||||||
|
import db = require('./db');
|
||||||
|
>db : Symbol(db, Decl(service.ts, 0, 0))
|
||||||
|
|
||||||
|
function someDecorator(target) {
|
||||||
|
>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 28))
|
||||||
|
>target : Symbol(target, Decl(service.ts, 1, 23))
|
||||||
|
|
||||||
|
return target;
|
||||||
|
>target : Symbol(target, Decl(service.ts, 1, 23))
|
||||||
|
}
|
||||||
|
@someDecorator
|
||||||
|
>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 28))
|
||||||
|
|
||||||
|
class MyClass {
|
||||||
|
>MyClass : Symbol(MyClass, Decl(service.ts, 3, 1))
|
||||||
|
|
||||||
|
db: db.db;
|
||||||
|
>db : Symbol(db, Decl(service.ts, 5, 15))
|
||||||
|
>db : Symbol(db, Decl(service.ts, 0, 0))
|
||||||
|
>db : Symbol(db.db, Decl(db.ts, 0, 0))
|
||||||
|
|
||||||
|
constructor(db: db.db) { // collision with namespace of external module db
|
||||||
|
>db : Symbol(db, Decl(service.ts, 8, 16))
|
||||||
|
>db : Symbol(db, Decl(service.ts, 0, 0))
|
||||||
|
>db : Symbol(db.db, Decl(db.ts, 0, 0))
|
||||||
|
|
||||||
|
this.db = db;
|
||||||
|
>this.db : Symbol(db, Decl(service.ts, 5, 15))
|
||||||
|
>this : Symbol(MyClass, Decl(service.ts, 3, 1))
|
||||||
|
>db : Symbol(db, Decl(service.ts, 5, 15))
|
||||||
|
>db : Symbol(db, Decl(service.ts, 8, 16))
|
||||||
|
|
||||||
|
this.db.doSomething();
|
||||||
|
>this.db.doSomething : Symbol(db.db.doSomething, Decl(db.ts, 0, 17))
|
||||||
|
>this.db : Symbol(db, Decl(service.ts, 5, 15))
|
||||||
|
>this : Symbol(MyClass, Decl(service.ts, 3, 1))
|
||||||
|
>db : Symbol(db, Decl(service.ts, 5, 15))
|
||||||
|
>doSomething : Symbol(db.db.doSomething, Decl(db.ts, 0, 17))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export {MyClass};
|
||||||
|
>MyClass : Symbol(MyClass, Decl(service.ts, 13, 8))
|
||||||
|
|
||||||
|
=== tests/cases/compiler/db.ts ===
|
||||||
|
export class db {
|
||||||
|
>db : Symbol(db, Decl(db.ts, 0, 0))
|
||||||
|
|
||||||
|
public doSomething() {
|
||||||
|
>doSomething : Symbol(doSomething, Decl(db.ts, 0, 17))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
=== tests/cases/compiler/service.ts ===
|
||||||
|
import db = require('./db');
|
||||||
|
>db : typeof db
|
||||||
|
|
||||||
|
function someDecorator(target) {
|
||||||
|
>someDecorator : (target: any) => any
|
||||||
|
>target : any
|
||||||
|
|
||||||
|
return target;
|
||||||
|
>target : any
|
||||||
|
}
|
||||||
|
@someDecorator
|
||||||
|
>someDecorator : (target: any) => any
|
||||||
|
|
||||||
|
class MyClass {
|
||||||
|
>MyClass : MyClass
|
||||||
|
|
||||||
|
db: db.db;
|
||||||
|
>db : db.db
|
||||||
|
>db : any
|
||||||
|
>db : db.db
|
||||||
|
|
||||||
|
constructor(db: db.db) { // collision with namespace of external module db
|
||||||
|
>db : db.db
|
||||||
|
>db : any
|
||||||
|
>db : db.db
|
||||||
|
|
||||||
|
this.db = db;
|
||||||
|
>this.db = db : db.db
|
||||||
|
>this.db : db.db
|
||||||
|
>this : MyClass
|
||||||
|
>db : db.db
|
||||||
|
>db : db.db
|
||||||
|
|
||||||
|
this.db.doSomething();
|
||||||
|
>this.db.doSomething() : void
|
||||||
|
>this.db.doSomething : () => void
|
||||||
|
>this.db : db.db
|
||||||
|
>this : MyClass
|
||||||
|
>db : db.db
|
||||||
|
>doSomething : () => void
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export {MyClass};
|
||||||
|
>MyClass : typeof MyClass
|
||||||
|
|
||||||
|
=== tests/cases/compiler/db.ts ===
|
||||||
|
export class db {
|
||||||
|
>db : db
|
||||||
|
|
||||||
|
public doSomething() {
|
||||||
|
>doSomething : () => void
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
tests/cases/compiler/service.ts(1,8): error TS1192: Module '"tests/cases/compiler/db"' has no default export.
|
||||||
|
|
||||||
|
|
||||||
|
==== tests/cases/compiler/db.ts (0 errors) ====
|
||||||
|
export class db {
|
||||||
|
public doSomething() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
==== tests/cases/compiler/service.ts (1 errors) ====
|
||||||
|
import db from './db'; // error no default export
|
||||||
|
~~
|
||||||
|
!!! error TS1192: Module '"tests/cases/compiler/db"' has no default export.
|
||||||
|
function someDecorator(target) {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
@someDecorator
|
||||||
|
class MyClass {
|
||||||
|
db: db.db;
|
||||||
|
|
||||||
|
constructor(db: db.db) {
|
||||||
|
this.db = db;
|
||||||
|
this.db.doSomething();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export {MyClass};
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision4.ts] ////
|
||||||
|
|
||||||
|
//// [db.ts]
|
||||||
|
export class db {
|
||||||
|
public doSomething() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//// [service.ts]
|
||||||
|
import db from './db'; // error no default export
|
||||||
|
function someDecorator(target) {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
@someDecorator
|
||||||
|
class MyClass {
|
||||||
|
db: db.db;
|
||||||
|
|
||||||
|
constructor(db: db.db) {
|
||||||
|
this.db = db;
|
||||||
|
this.db.doSomething();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export {MyClass};
|
||||||
|
|
||||||
|
|
||||||
|
//// [db.js]
|
||||||
|
var db = (function () {
|
||||||
|
function db() {
|
||||||
|
}
|
||||||
|
db.prototype.doSomething = function () {
|
||||||
|
};
|
||||||
|
return db;
|
||||||
|
})();
|
||||||
|
exports.db = db;
|
||||||
|
//// [service.js]
|
||||||
|
var db_1 = require('./db'); // error no default export
|
||||||
|
function someDecorator(target) {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
var MyClass = (function () {
|
||||||
|
function MyClass(db) {
|
||||||
|
this.db = db;
|
||||||
|
this.db.doSomething();
|
||||||
|
}
|
||||||
|
MyClass = __decorate([
|
||||||
|
someDecorator,
|
||||||
|
__metadata('design:paramtypes', [Object])
|
||||||
|
], MyClass);
|
||||||
|
return MyClass;
|
||||||
|
})();
|
||||||
|
exports.MyClass = MyClass;
|
|
@ -0,0 +1,52 @@
|
||||||
|
//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision5.ts] ////
|
||||||
|
|
||||||
|
//// [db.ts]
|
||||||
|
export default class db {
|
||||||
|
public doSomething() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//// [service.ts]
|
||||||
|
import db from './db';
|
||||||
|
function someDecorator(target) {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
@someDecorator
|
||||||
|
class MyClass {
|
||||||
|
db: db;
|
||||||
|
|
||||||
|
constructor(db: db) { // collision
|
||||||
|
this.db = db;
|
||||||
|
this.db.doSomething();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export {MyClass};
|
||||||
|
|
||||||
|
|
||||||
|
//// [db.js]
|
||||||
|
var db = (function () {
|
||||||
|
function db() {
|
||||||
|
}
|
||||||
|
db.prototype.doSomething = function () {
|
||||||
|
};
|
||||||
|
return db;
|
||||||
|
})();
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.default = db;
|
||||||
|
//// [service.js]
|
||||||
|
var db_1 = require('./db');
|
||||||
|
function someDecorator(target) {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
var MyClass = (function () {
|
||||||
|
function MyClass(db) {
|
||||||
|
this.db = db;
|
||||||
|
this.db.doSomething();
|
||||||
|
}
|
||||||
|
MyClass = __decorate([
|
||||||
|
someDecorator,
|
||||||
|
__metadata('design:paramtypes', [db_1.default])
|
||||||
|
], MyClass);
|
||||||
|
return MyClass;
|
||||||
|
})();
|
||||||
|
exports.MyClass = MyClass;
|
|
@ -0,0 +1,51 @@
|
||||||
|
=== tests/cases/compiler/db.ts ===
|
||||||
|
export default class db {
|
||||||
|
>db : Symbol(db, Decl(db.ts, 0, 0))
|
||||||
|
|
||||||
|
public doSomething() {
|
||||||
|
>doSomething : Symbol(doSomething, Decl(db.ts, 0, 25))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
=== tests/cases/compiler/service.ts ===
|
||||||
|
import db from './db';
|
||||||
|
>db : Symbol(db, Decl(service.ts, 0, 6))
|
||||||
|
|
||||||
|
function someDecorator(target) {
|
||||||
|
>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 22))
|
||||||
|
>target : Symbol(target, Decl(service.ts, 1, 23))
|
||||||
|
|
||||||
|
return target;
|
||||||
|
>target : Symbol(target, Decl(service.ts, 1, 23))
|
||||||
|
}
|
||||||
|
@someDecorator
|
||||||
|
>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 22))
|
||||||
|
|
||||||
|
class MyClass {
|
||||||
|
>MyClass : Symbol(MyClass, Decl(service.ts, 3, 1))
|
||||||
|
|
||||||
|
db: db;
|
||||||
|
>db : Symbol(db, Decl(service.ts, 5, 15))
|
||||||
|
>db : Symbol(db, Decl(service.ts, 0, 6))
|
||||||
|
|
||||||
|
constructor(db: db) { // collision
|
||||||
|
>db : Symbol(db, Decl(service.ts, 8, 16))
|
||||||
|
>db : Symbol(db, Decl(service.ts, 0, 6))
|
||||||
|
|
||||||
|
this.db = db;
|
||||||
|
>this.db : Symbol(db, Decl(service.ts, 5, 15))
|
||||||
|
>this : Symbol(MyClass, Decl(service.ts, 3, 1))
|
||||||
|
>db : Symbol(db, Decl(service.ts, 5, 15))
|
||||||
|
>db : Symbol(db, Decl(service.ts, 8, 16))
|
||||||
|
|
||||||
|
this.db.doSomething();
|
||||||
|
>this.db.doSomething : Symbol(db.doSomething, Decl(db.ts, 0, 25))
|
||||||
|
>this.db : Symbol(db, Decl(service.ts, 5, 15))
|
||||||
|
>this : Symbol(MyClass, Decl(service.ts, 3, 1))
|
||||||
|
>db : Symbol(db, Decl(service.ts, 5, 15))
|
||||||
|
>doSomething : Symbol(db.doSomething, Decl(db.ts, 0, 25))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export {MyClass};
|
||||||
|
>MyClass : Symbol(MyClass, Decl(service.ts, 13, 8))
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
=== tests/cases/compiler/db.ts ===
|
||||||
|
export default class db {
|
||||||
|
>db : db
|
||||||
|
|
||||||
|
public doSomething() {
|
||||||
|
>doSomething : () => void
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
=== tests/cases/compiler/service.ts ===
|
||||||
|
import db from './db';
|
||||||
|
>db : typeof db
|
||||||
|
|
||||||
|
function someDecorator(target) {
|
||||||
|
>someDecorator : (target: any) => any
|
||||||
|
>target : any
|
||||||
|
|
||||||
|
return target;
|
||||||
|
>target : any
|
||||||
|
}
|
||||||
|
@someDecorator
|
||||||
|
>someDecorator : (target: any) => any
|
||||||
|
|
||||||
|
class MyClass {
|
||||||
|
>MyClass : MyClass
|
||||||
|
|
||||||
|
db: db;
|
||||||
|
>db : db
|
||||||
|
>db : db
|
||||||
|
|
||||||
|
constructor(db: db) { // collision
|
||||||
|
>db : db
|
||||||
|
>db : db
|
||||||
|
|
||||||
|
this.db = db;
|
||||||
|
>this.db = db : db
|
||||||
|
>this.db : db
|
||||||
|
>this : MyClass
|
||||||
|
>db : db
|
||||||
|
>db : db
|
||||||
|
|
||||||
|
this.db.doSomething();
|
||||||
|
>this.db.doSomething() : void
|
||||||
|
>this.db.doSomething : () => void
|
||||||
|
>this.db : db
|
||||||
|
>this : MyClass
|
||||||
|
>db : db
|
||||||
|
>doSomething : () => void
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export {MyClass};
|
||||||
|
>MyClass : typeof MyClass
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision6.ts] ////
|
||||||
|
|
||||||
|
//// [db.ts]
|
||||||
|
export default class db {
|
||||||
|
public doSomething() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//// [service.ts]
|
||||||
|
import database from './db';
|
||||||
|
function someDecorator(target) {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
@someDecorator
|
||||||
|
class MyClass {
|
||||||
|
db: database;
|
||||||
|
|
||||||
|
constructor(db: database) { // no collision
|
||||||
|
this.db = db;
|
||||||
|
this.db.doSomething();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export {MyClass};
|
||||||
|
|
||||||
|
|
||||||
|
//// [db.js]
|
||||||
|
var db = (function () {
|
||||||
|
function db() {
|
||||||
|
}
|
||||||
|
db.prototype.doSomething = function () {
|
||||||
|
};
|
||||||
|
return db;
|
||||||
|
})();
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.default = db;
|
||||||
|
//// [service.js]
|
||||||
|
var db_1 = require('./db');
|
||||||
|
function someDecorator(target) {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
var MyClass = (function () {
|
||||||
|
function MyClass(db) {
|
||||||
|
this.db = db;
|
||||||
|
this.db.doSomething();
|
||||||
|
}
|
||||||
|
MyClass = __decorate([
|
||||||
|
someDecorator,
|
||||||
|
__metadata('design:paramtypes', [db_1.default])
|
||||||
|
], MyClass);
|
||||||
|
return MyClass;
|
||||||
|
})();
|
||||||
|
exports.MyClass = MyClass;
|
|
@ -0,0 +1,51 @@
|
||||||
|
=== tests/cases/compiler/db.ts ===
|
||||||
|
export default class db {
|
||||||
|
>db : Symbol(db, Decl(db.ts, 0, 0))
|
||||||
|
|
||||||
|
public doSomething() {
|
||||||
|
>doSomething : Symbol(doSomething, Decl(db.ts, 0, 25))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
=== tests/cases/compiler/service.ts ===
|
||||||
|
import database from './db';
|
||||||
|
>database : Symbol(database, Decl(service.ts, 0, 6))
|
||||||
|
|
||||||
|
function someDecorator(target) {
|
||||||
|
>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 28))
|
||||||
|
>target : Symbol(target, Decl(service.ts, 1, 23))
|
||||||
|
|
||||||
|
return target;
|
||||||
|
>target : Symbol(target, Decl(service.ts, 1, 23))
|
||||||
|
}
|
||||||
|
@someDecorator
|
||||||
|
>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 28))
|
||||||
|
|
||||||
|
class MyClass {
|
||||||
|
>MyClass : Symbol(MyClass, Decl(service.ts, 3, 1))
|
||||||
|
|
||||||
|
db: database;
|
||||||
|
>db : Symbol(db, Decl(service.ts, 5, 15))
|
||||||
|
>database : Symbol(database, Decl(service.ts, 0, 6))
|
||||||
|
|
||||||
|
constructor(db: database) { // no collision
|
||||||
|
>db : Symbol(db, Decl(service.ts, 8, 16))
|
||||||
|
>database : Symbol(database, Decl(service.ts, 0, 6))
|
||||||
|
|
||||||
|
this.db = db;
|
||||||
|
>this.db : Symbol(db, Decl(service.ts, 5, 15))
|
||||||
|
>this : Symbol(MyClass, Decl(service.ts, 3, 1))
|
||||||
|
>db : Symbol(db, Decl(service.ts, 5, 15))
|
||||||
|
>db : Symbol(db, Decl(service.ts, 8, 16))
|
||||||
|
|
||||||
|
this.db.doSomething();
|
||||||
|
>this.db.doSomething : Symbol(database.doSomething, Decl(db.ts, 0, 25))
|
||||||
|
>this.db : Symbol(db, Decl(service.ts, 5, 15))
|
||||||
|
>this : Symbol(MyClass, Decl(service.ts, 3, 1))
|
||||||
|
>db : Symbol(db, Decl(service.ts, 5, 15))
|
||||||
|
>doSomething : Symbol(database.doSomething, Decl(db.ts, 0, 25))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export {MyClass};
|
||||||
|
>MyClass : Symbol(MyClass, Decl(service.ts, 13, 8))
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
=== tests/cases/compiler/db.ts ===
|
||||||
|
export default class db {
|
||||||
|
>db : db
|
||||||
|
|
||||||
|
public doSomething() {
|
||||||
|
>doSomething : () => void
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
=== tests/cases/compiler/service.ts ===
|
||||||
|
import database from './db';
|
||||||
|
>database : typeof database
|
||||||
|
|
||||||
|
function someDecorator(target) {
|
||||||
|
>someDecorator : (target: any) => any
|
||||||
|
>target : any
|
||||||
|
|
||||||
|
return target;
|
||||||
|
>target : any
|
||||||
|
}
|
||||||
|
@someDecorator
|
||||||
|
>someDecorator : (target: any) => any
|
||||||
|
|
||||||
|
class MyClass {
|
||||||
|
>MyClass : MyClass
|
||||||
|
|
||||||
|
db: database;
|
||||||
|
>db : database
|
||||||
|
>database : database
|
||||||
|
|
||||||
|
constructor(db: database) { // no collision
|
||||||
|
>db : database
|
||||||
|
>database : database
|
||||||
|
|
||||||
|
this.db = db;
|
||||||
|
>this.db = db : database
|
||||||
|
>this.db : database
|
||||||
|
>this : MyClass
|
||||||
|
>db : database
|
||||||
|
>db : database
|
||||||
|
|
||||||
|
this.db.doSomething();
|
||||||
|
>this.db.doSomething() : void
|
||||||
|
>this.db.doSomething : () => void
|
||||||
|
>this.db : database
|
||||||
|
>this : MyClass
|
||||||
|
>db : database
|
||||||
|
>doSomething : () => void
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export {MyClass};
|
||||||
|
>MyClass : typeof MyClass
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
tests/cases/compiler/service.ts(7,9): error TS2503: Cannot find namespace 'db'.
|
||||||
|
tests/cases/compiler/service.ts(9,21): error TS2503: Cannot find namespace 'db'.
|
||||||
|
|
||||||
|
|
||||||
|
==== tests/cases/compiler/db.ts (0 errors) ====
|
||||||
|
export default class db {
|
||||||
|
public doSomething() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
==== tests/cases/compiler/service.ts (2 errors) ====
|
||||||
|
import db from './db';
|
||||||
|
function someDecorator(target) {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
@someDecorator
|
||||||
|
class MyClass {
|
||||||
|
db: db.db; //error
|
||||||
|
~~
|
||||||
|
!!! error TS2503: Cannot find namespace 'db'.
|
||||||
|
|
||||||
|
constructor(db: db.db) { // error
|
||||||
|
~~
|
||||||
|
!!! error TS2503: Cannot find namespace 'db'.
|
||||||
|
this.db = db;
|
||||||
|
this.db.doSomething();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export {MyClass};
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision7.ts] ////
|
||||||
|
|
||||||
|
//// [db.ts]
|
||||||
|
export default class db {
|
||||||
|
public doSomething() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//// [service.ts]
|
||||||
|
import db from './db';
|
||||||
|
function someDecorator(target) {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
@someDecorator
|
||||||
|
class MyClass {
|
||||||
|
db: db.db; //error
|
||||||
|
|
||||||
|
constructor(db: db.db) { // error
|
||||||
|
this.db = db;
|
||||||
|
this.db.doSomething();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export {MyClass};
|
||||||
|
|
||||||
|
|
||||||
|
//// [db.js]
|
||||||
|
var db = (function () {
|
||||||
|
function db() {
|
||||||
|
}
|
||||||
|
db.prototype.doSomething = function () {
|
||||||
|
};
|
||||||
|
return db;
|
||||||
|
})();
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.default = db;
|
||||||
|
//// [service.js]
|
||||||
|
var db_1 = require('./db');
|
||||||
|
function someDecorator(target) {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
var MyClass = (function () {
|
||||||
|
function MyClass(db) {
|
||||||
|
this.db = db;
|
||||||
|
this.db.doSomething();
|
||||||
|
}
|
||||||
|
MyClass = __decorate([
|
||||||
|
someDecorator,
|
||||||
|
__metadata('design:paramtypes', [Object])
|
||||||
|
], MyClass);
|
||||||
|
return MyClass;
|
||||||
|
})();
|
||||||
|
exports.MyClass = MyClass;
|
|
@ -0,0 +1,51 @@
|
||||||
|
//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision8.ts] ////
|
||||||
|
|
||||||
|
//// [db.ts]
|
||||||
|
export class db {
|
||||||
|
public doSomething() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//// [service.ts]
|
||||||
|
import database = require('./db');
|
||||||
|
function someDecorator(target) {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
@someDecorator
|
||||||
|
class MyClass {
|
||||||
|
db: database.db;
|
||||||
|
|
||||||
|
constructor(db: database.db) { // no collision
|
||||||
|
this.db = db;
|
||||||
|
this.db.doSomething();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export {MyClass};
|
||||||
|
|
||||||
|
|
||||||
|
//// [db.js]
|
||||||
|
var db = (function () {
|
||||||
|
function db() {
|
||||||
|
}
|
||||||
|
db.prototype.doSomething = function () {
|
||||||
|
};
|
||||||
|
return db;
|
||||||
|
})();
|
||||||
|
exports.db = db;
|
||||||
|
//// [service.js]
|
||||||
|
var database = require('./db');
|
||||||
|
function someDecorator(target) {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
var MyClass = (function () {
|
||||||
|
function MyClass(db) {
|
||||||
|
this.db = db;
|
||||||
|
this.db.doSomething();
|
||||||
|
}
|
||||||
|
MyClass = __decorate([
|
||||||
|
someDecorator,
|
||||||
|
__metadata('design:paramtypes', [database.db])
|
||||||
|
], MyClass);
|
||||||
|
return MyClass;
|
||||||
|
})();
|
||||||
|
exports.MyClass = MyClass;
|
|
@ -0,0 +1,53 @@
|
||||||
|
=== tests/cases/compiler/service.ts ===
|
||||||
|
import database = require('./db');
|
||||||
|
>database : Symbol(database, Decl(service.ts, 0, 0))
|
||||||
|
|
||||||
|
function someDecorator(target) {
|
||||||
|
>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 34))
|
||||||
|
>target : Symbol(target, Decl(service.ts, 1, 23))
|
||||||
|
|
||||||
|
return target;
|
||||||
|
>target : Symbol(target, Decl(service.ts, 1, 23))
|
||||||
|
}
|
||||||
|
@someDecorator
|
||||||
|
>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 34))
|
||||||
|
|
||||||
|
class MyClass {
|
||||||
|
>MyClass : Symbol(MyClass, Decl(service.ts, 3, 1))
|
||||||
|
|
||||||
|
db: database.db;
|
||||||
|
>db : Symbol(db, Decl(service.ts, 5, 15))
|
||||||
|
>database : Symbol(database, Decl(service.ts, 0, 0))
|
||||||
|
>db : Symbol(database.db, Decl(db.ts, 0, 0))
|
||||||
|
|
||||||
|
constructor(db: database.db) { // no collision
|
||||||
|
>db : Symbol(db, Decl(service.ts, 8, 16))
|
||||||
|
>database : Symbol(database, Decl(service.ts, 0, 0))
|
||||||
|
>db : Symbol(database.db, Decl(db.ts, 0, 0))
|
||||||
|
|
||||||
|
this.db = db;
|
||||||
|
>this.db : Symbol(db, Decl(service.ts, 5, 15))
|
||||||
|
>this : Symbol(MyClass, Decl(service.ts, 3, 1))
|
||||||
|
>db : Symbol(db, Decl(service.ts, 5, 15))
|
||||||
|
>db : Symbol(db, Decl(service.ts, 8, 16))
|
||||||
|
|
||||||
|
this.db.doSomething();
|
||||||
|
>this.db.doSomething : Symbol(database.db.doSomething, Decl(db.ts, 0, 17))
|
||||||
|
>this.db : Symbol(db, Decl(service.ts, 5, 15))
|
||||||
|
>this : Symbol(MyClass, Decl(service.ts, 3, 1))
|
||||||
|
>db : Symbol(db, Decl(service.ts, 5, 15))
|
||||||
|
>doSomething : Symbol(database.db.doSomething, Decl(db.ts, 0, 17))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export {MyClass};
|
||||||
|
>MyClass : Symbol(MyClass, Decl(service.ts, 13, 8))
|
||||||
|
|
||||||
|
=== tests/cases/compiler/db.ts ===
|
||||||
|
export class db {
|
||||||
|
>db : Symbol(db, Decl(db.ts, 0, 0))
|
||||||
|
|
||||||
|
public doSomething() {
|
||||||
|
>doSomething : Symbol(doSomething, Decl(db.ts, 0, 17))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
=== tests/cases/compiler/service.ts ===
|
||||||
|
import database = require('./db');
|
||||||
|
>database : typeof database
|
||||||
|
|
||||||
|
function someDecorator(target) {
|
||||||
|
>someDecorator : (target: any) => any
|
||||||
|
>target : any
|
||||||
|
|
||||||
|
return target;
|
||||||
|
>target : any
|
||||||
|
}
|
||||||
|
@someDecorator
|
||||||
|
>someDecorator : (target: any) => any
|
||||||
|
|
||||||
|
class MyClass {
|
||||||
|
>MyClass : MyClass
|
||||||
|
|
||||||
|
db: database.db;
|
||||||
|
>db : database.db
|
||||||
|
>database : any
|
||||||
|
>db : database.db
|
||||||
|
|
||||||
|
constructor(db: database.db) { // no collision
|
||||||
|
>db : database.db
|
||||||
|
>database : any
|
||||||
|
>db : database.db
|
||||||
|
|
||||||
|
this.db = db;
|
||||||
|
>this.db = db : database.db
|
||||||
|
>this.db : database.db
|
||||||
|
>this : MyClass
|
||||||
|
>db : database.db
|
||||||
|
>db : database.db
|
||||||
|
|
||||||
|
this.db.doSomething();
|
||||||
|
>this.db.doSomething() : void
|
||||||
|
>this.db.doSomething : () => void
|
||||||
|
>this.db : database.db
|
||||||
|
>this : MyClass
|
||||||
|
>db : database.db
|
||||||
|
>doSomething : () => void
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export {MyClass};
|
||||||
|
>MyClass : typeof MyClass
|
||||||
|
|
||||||
|
=== tests/cases/compiler/db.ts ===
|
||||||
|
export class db {
|
||||||
|
>db : db
|
||||||
|
|
||||||
|
public doSomething() {
|
||||||
|
>doSomething : () => void
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
// @noemithelpers: true
|
||||||
|
// @experimentaldecorators: true
|
||||||
|
// @emitdecoratormetadata: true
|
||||||
|
// @target: es5
|
||||||
|
// @module: commonjs
|
||||||
|
// @filename: db.ts
|
||||||
|
export class db {
|
||||||
|
public doSomething() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// @filename: service.ts
|
||||||
|
import {db} from './db';
|
||||||
|
function someDecorator(target) {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
@someDecorator
|
||||||
|
class MyClass {
|
||||||
|
db: db;
|
||||||
|
|
||||||
|
constructor(db: db) {
|
||||||
|
this.db = db;
|
||||||
|
this.db.doSomething();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export {MyClass};
|
|
@ -0,0 +1,26 @@
|
||||||
|
// @noemithelpers: true
|
||||||
|
// @experimentaldecorators: true
|
||||||
|
// @emitdecoratormetadata: true
|
||||||
|
// @target: es5
|
||||||
|
// @module: commonjs
|
||||||
|
// @filename: db.ts
|
||||||
|
export class db {
|
||||||
|
public doSomething() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// @filename: service.ts
|
||||||
|
import {db as Database} from './db';
|
||||||
|
function someDecorator(target) {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
@someDecorator
|
||||||
|
class MyClass {
|
||||||
|
db: Database;
|
||||||
|
|
||||||
|
constructor(db: Database) { // no collision
|
||||||
|
this.db = db;
|
||||||
|
this.db.doSomething();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export {MyClass};
|
|
@ -0,0 +1,26 @@
|
||||||
|
// @noemithelpers: true
|
||||||
|
// @experimentaldecorators: true
|
||||||
|
// @emitdecoratormetadata: true
|
||||||
|
// @target: es5
|
||||||
|
// @module: commonjs
|
||||||
|
// @filename: db.ts
|
||||||
|
export class db {
|
||||||
|
public doSomething() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// @filename: service.ts
|
||||||
|
import db = require('./db');
|
||||||
|
function someDecorator(target) {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
@someDecorator
|
||||||
|
class MyClass {
|
||||||
|
db: db.db;
|
||||||
|
|
||||||
|
constructor(db: db.db) { // collision with namespace of external module db
|
||||||
|
this.db = db;
|
||||||
|
this.db.doSomething();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export {MyClass};
|
|
@ -0,0 +1,26 @@
|
||||||
|
// @noemithelpers: true
|
||||||
|
// @experimentaldecorators: true
|
||||||
|
// @emitdecoratormetadata: true
|
||||||
|
// @target: es5
|
||||||
|
// @module: commonjs
|
||||||
|
// @filename: db.ts
|
||||||
|
export class db {
|
||||||
|
public doSomething() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// @filename: service.ts
|
||||||
|
import db from './db'; // error no default export
|
||||||
|
function someDecorator(target) {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
@someDecorator
|
||||||
|
class MyClass {
|
||||||
|
db: db.db;
|
||||||
|
|
||||||
|
constructor(db: db.db) {
|
||||||
|
this.db = db;
|
||||||
|
this.db.doSomething();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export {MyClass};
|
|
@ -0,0 +1,26 @@
|
||||||
|
// @noemithelpers: true
|
||||||
|
// @experimentaldecorators: true
|
||||||
|
// @emitdecoratormetadata: true
|
||||||
|
// @target: es5
|
||||||
|
// @module: commonjs
|
||||||
|
// @filename: db.ts
|
||||||
|
export default class db {
|
||||||
|
public doSomething() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// @filename: service.ts
|
||||||
|
import db from './db';
|
||||||
|
function someDecorator(target) {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
@someDecorator
|
||||||
|
class MyClass {
|
||||||
|
db: db;
|
||||||
|
|
||||||
|
constructor(db: db) { // collision
|
||||||
|
this.db = db;
|
||||||
|
this.db.doSomething();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export {MyClass};
|
|
@ -0,0 +1,26 @@
|
||||||
|
// @noemithelpers: true
|
||||||
|
// @experimentaldecorators: true
|
||||||
|
// @emitdecoratormetadata: true
|
||||||
|
// @target: es5
|
||||||
|
// @module: commonjs
|
||||||
|
// @filename: db.ts
|
||||||
|
export default class db {
|
||||||
|
public doSomething() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// @filename: service.ts
|
||||||
|
import database from './db';
|
||||||
|
function someDecorator(target) {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
@someDecorator
|
||||||
|
class MyClass {
|
||||||
|
db: database;
|
||||||
|
|
||||||
|
constructor(db: database) { // no collision
|
||||||
|
this.db = db;
|
||||||
|
this.db.doSomething();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export {MyClass};
|
|
@ -0,0 +1,26 @@
|
||||||
|
// @noemithelpers: true
|
||||||
|
// @experimentaldecorators: true
|
||||||
|
// @emitdecoratormetadata: true
|
||||||
|
// @target: es5
|
||||||
|
// @module: commonjs
|
||||||
|
// @filename: db.ts
|
||||||
|
export default class db {
|
||||||
|
public doSomething() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// @filename: service.ts
|
||||||
|
import db from './db';
|
||||||
|
function someDecorator(target) {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
@someDecorator
|
||||||
|
class MyClass {
|
||||||
|
db: db.db; //error
|
||||||
|
|
||||||
|
constructor(db: db.db) { // error
|
||||||
|
this.db = db;
|
||||||
|
this.db.doSomething();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export {MyClass};
|
|
@ -0,0 +1,26 @@
|
||||||
|
// @noemithelpers: true
|
||||||
|
// @experimentaldecorators: true
|
||||||
|
// @emitdecoratormetadata: true
|
||||||
|
// @target: es5
|
||||||
|
// @module: commonjs
|
||||||
|
// @filename: db.ts
|
||||||
|
export class db {
|
||||||
|
public doSomething() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// @filename: service.ts
|
||||||
|
import database = require('./db');
|
||||||
|
function someDecorator(target) {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
@someDecorator
|
||||||
|
class MyClass {
|
||||||
|
db: database.db;
|
||||||
|
|
||||||
|
constructor(db: database.db) { // no collision
|
||||||
|
this.db = db;
|
||||||
|
this.db.doSomething();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export {MyClass};
|
|
@ -221,5 +221,54 @@ var x = 0;`,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("Transpile with emit decorators and emit metadata", () => {
|
||||||
|
let input =
|
||||||
|
`import {db} from './db';\n` +
|
||||||
|
`function someDecorator(target) {\n` +
|
||||||
|
` return target;\n` +
|
||||||
|
`} \n` +
|
||||||
|
`@someDecorator\n` +
|
||||||
|
`class MyClass {\n` +
|
||||||
|
` db: db;\n` +
|
||||||
|
` constructor(db: db) {\n` +
|
||||||
|
` this.db = db;\n` +
|
||||||
|
` this.db.doSomething(); \n` +
|
||||||
|
` }\n` +
|
||||||
|
`}\n` +
|
||||||
|
`export {MyClass}; \n`
|
||||||
|
let output =
|
||||||
|
`var db_1 = require(\'./db\');\n` +
|
||||||
|
`function someDecorator(target) {\n` +
|
||||||
|
` return target;\n` +
|
||||||
|
`}\n` +
|
||||||
|
`var MyClass = (function () {\n` +
|
||||||
|
` function MyClass(db) {\n` +
|
||||||
|
` this.db = db;\n` +
|
||||||
|
` this.db.doSomething();\n` +
|
||||||
|
` }\n` +
|
||||||
|
` MyClass = __decorate([\n` +
|
||||||
|
` someDecorator, \n` +
|
||||||
|
` __metadata(\'design:paramtypes\', [(typeof (_a = typeof db_1.db !== \'undefined\' && db_1.db) === \'function\' && _a) || Object])\n` +
|
||||||
|
` ], MyClass);\n` +
|
||||||
|
` return MyClass;\n` +
|
||||||
|
` var _a;\n` +
|
||||||
|
`})();\n` +
|
||||||
|
`exports.MyClass = MyClass;\n`;
|
||||||
|
|
||||||
|
test(input,
|
||||||
|
{
|
||||||
|
options: {
|
||||||
|
compilerOptions: {
|
||||||
|
module: ModuleKind.CommonJS,
|
||||||
|
newLine: NewLineKind.LineFeed,
|
||||||
|
noEmitHelpers: true,
|
||||||
|
emitDecoratorMetadata: true,
|
||||||
|
experimentalDecorators: true,
|
||||||
|
target: ScriptTarget.ES5,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
expectedOutput: output
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue