diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d087059d19e..e5b5299ff44 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4379,8 +4379,8 @@ module ts { function getNarrowedTypeOfSymbol(symbol: Symbol, node: Node) { var type = getTypeOfSymbol(symbol); // Only narrow when symbol is variable of a structured type - if (node && node.parent && (symbol.flags & SymbolFlags.Variable && type.flags & TypeFlags.Structured)) { - loop: while (true) { + if (node && (symbol.flags & SymbolFlags.Variable && type.flags & TypeFlags.Structured)) { + loop: while (node.parent) { var child = node; node = node.parent; var narrowedType = type;