mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
add condition to bail at containing level
This commit is contained in:
@@ -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};
|
||||
|
||||
Reference in New Issue
Block a user