mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-19 01:33:15 -05:00
Merge branch 'master' into use-common-directory-for-out
This commit is contained in:
@@ -6427,6 +6427,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) {
|
||||
@@ -6440,15 +6442,12 @@ namespace ts {
|
||||
break;
|
||||
case SyntaxKind.SourceFile:
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.Constructor:
|
||||
// Stop at the first containing function or module declaration
|
||||
// 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