Resolve the decorator type as type and check if the symbol has value.

This would make sure we are referencing correct symbol to check if it has value
Fixes #4239
This commit is contained in:
Sheetal Nandi 2015-08-20 15:45:51 -07:00
parent 8ad9138828
commit 345de8fca5
2 changed files with 11 additions and 3 deletions

View File

@ -11384,9 +11384,16 @@ namespace ts {
// serialize the type metadata.
if (node && node.kind === SyntaxKind.TypeReference) {
let root = getFirstIdentifier((<TypeReferenceNode>node).typeName);
let rootSymbol = resolveName(root, root.text, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined);
if (rootSymbol && rootSymbol.flags & SymbolFlags.Alias && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) {
markAliasSymbolAsReferenced(rootSymbol);
var meaning = root.parent.kind === SyntaxKind.TypeReference ? SymbolFlags.Type : SymbolFlags.Namespace;
// 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);
}
}
}
}

View File

@ -34,6 +34,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var service_1 = require("./service");
var MyComponent = (function () {
function MyComponent(Service) {
this.Service = Service;