diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7f1450efac9..025d3380a20 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4880,11 +4880,13 @@ module ts { var symbol = getResolvedSymbol(node); if (symbol.flags & SymbolFlags.Import) { - var symbolLinks = getSymbolLinks(symbol); symbolLinks.referenced = !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveImport(symbol)); - // TODO(andersh): Figure out what this does + // TODO: AndersH: This needs to be simplified. In an import of the form "import x = a.b.c;" we only need + // to resolve "a" and mark it as referenced. If "b" and/or "c" are aliases, we would be able to access them + // unless they're exported, and in that case they're already implicitly referenced. + //var symbolLinks = getSymbolLinks(symbol); //if (!symbolLinks.referenced) { // var importOrExportAssignment = getLeftSideOfImportEqualsOrExportAssignment(node); diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index ec2c2d404da..d417bc1d380 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -753,36 +753,12 @@ module ts { } export function getAncestor(node: Node, kind: SyntaxKind): Node { - switch (kind) { - // special-cases that can be come first - case SyntaxKind.ClassDeclaration: - while (node) { - switch (node.kind) { - case SyntaxKind.ClassDeclaration: - return node; - case SyntaxKind.EnumDeclaration: - case SyntaxKind.InterfaceDeclaration: - case SyntaxKind.TypeAliasDeclaration: - case SyntaxKind.ModuleDeclaration: - case SyntaxKind.ImportEqualsDeclaration: - // early exit cases - declarations cannot be nested in classes - return undefined; - default: - node = node.parent; - continue; - } - } - break; - default: - while (node) { - if (node.kind === kind) { - return node; - } - node = node.parent; - } - break; + while (node) { + if (node.kind === kind) { + return node; + } + node = node.parent; } - return undefined; }