File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6386,6 +6386,8 @@ namespace ts {
63866386 // Only narrow when symbol is variable of type any or an object, union, or type parameter type
63876387 if (node && symbol.flags & SymbolFlags.Variable) {
63886388 if (isTypeAny(type) || type.flags & (TypeFlags.ObjectType | TypeFlags.Union | TypeFlags.TypeParameter)) {
6389+ const declaration = getDeclarationOfKind(symbol, SyntaxKind.VariableDeclaration);
6390+ const top = declaration && getDeclarationContainer(declaration);
63896391 const originalType = type;
63906392 const nodeStack: {node: Node, child: Node}[] = [];
63916393 loop: while (node.parent) {
@@ -6402,6 +6404,9 @@ namespace ts {
64026404 // Stop at the first containing file or module declaration
64036405 break loop;
64046406 }
6407+ if (node === top) {
6408+ break;
6409+ }
64056410 }
64066411
64076412 let nodes: {node: Node, child: Node};
You can’t perform that action at this time.
0 commit comments