From 187eaaee7f37ffffb92fa398d280abb527be6fa2 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 7 Mar 2016 13:20:07 -0800 Subject: [PATCH] Fix issue with narrowing exported variables --- src/compiler/checker.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9d05bc60c27..f18239d5e74 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7165,12 +7165,11 @@ namespace ts { if (!leftmostIdentifier) { return type; } - const leftmostSymbol = getResolvedSymbol(leftmostIdentifier); - if (!(leftmostSymbol.flags & SymbolFlags.Variable)) { + const declaration = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(leftmostIdentifier)).valueDeclaration; + if (!declaration || declaration.kind !== SyntaxKind.VariableDeclaration && declaration.kind !== SyntaxKind.Parameter && declaration.kind !== SyntaxKind.BindingElement) { return type; } - const declaration = getDeclarationOfKind(leftmostSymbol, SyntaxKind.VariableDeclaration); - const top = declaration && getDeclarationContainer(declaration); + const top = getDeclarationContainer(declaration); const originalType = type; const nodeStack: { node: Node, child: Node }[] = []; let node: Node = reference;