Merge pull request #8295 from Microsoft/anyDefaultsToAny

Variable of type any has initial type any in control flow analysis
This commit is contained in:
Anders Hejlsberg
2016-04-25 21:41:30 -07:00
5 changed files with 72 additions and 1 deletions

View File

@@ -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)) {