add condition to bail at containing level

This commit is contained in:
Wesley Wigham
2015-11-11 15:48:41 -08:00
parent 6c29ddf162
commit 472afc4e16
+5
View File
@@ -6386,6 +6386,8 @@ namespace ts {
// Only narrow when symbol is variable of type any or an object, union, or type parameter type
if (node && symbol.flags & SymbolFlags.Variable) {
if (isTypeAny(type) || type.flags & (TypeFlags.ObjectType | TypeFlags.Union | TypeFlags.TypeParameter)) {
const declaration = getDeclarationOfKind(symbol, SyntaxKind.VariableDeclaration);
const top = declaration && getDeclarationContainer(declaration);
const originalType = type;
const nodeStack: {node: Node, child: Node}[] = [];
loop: while (node.parent) {
@@ -6402,6 +6404,9 @@ namespace ts {
// Stop at the first containing file or module declaration
break loop;
}
if (node === top) {
break;
}
}
let nodes: {node: Node, child: Node};