From ecc936167fba12ac8709053621fd8cd2a9b7c661 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 25 Apr 2016 17:22:06 -0700 Subject: [PATCH] Variable of type any has initial type any in control flow analysis --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 992fc466dd7..6a42dc43d51 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7972,7 +7972,7 @@ namespace ts { return type; } const declaration = localOrExportSymbol.valueDeclaration; - const defaultsToDeclaredType = !strictNullChecks || !declaration || + const defaultsToDeclaredType = !strictNullChecks || type.flags & TypeFlags.Any || !declaration || declaration.kind === SyntaxKind.Parameter || isInAmbientContext(declaration) || getContainingFunctionOrModule(declaration) !== getContainingFunctionOrModule(node); if (defaultsToDeclaredType && !(type.flags & TypeFlags.Narrowable)) {