Correct handling of destructuring parameters in control flow analysis

This commit is contained in:
Anders Hejlsberg
2016-04-29 13:57:28 -07:00
parent 91201211f4
commit bd08e882fa
+1 -1
View File
@@ -7959,7 +7959,7 @@ namespace ts {
}
const declaration = localOrExportSymbol.valueDeclaration;
const defaultsToDeclaredType = !strictNullChecks || type.flags & TypeFlags.Any || !declaration ||
declaration.kind === SyntaxKind.Parameter || isInAmbientContext(declaration) ||
getRootDeclaration(declaration).kind === SyntaxKind.Parameter || isInAmbientContext(declaration) ||
getContainingFunctionOrModule(declaration) !== getContainingFunctionOrModule(node);
const flowType = getFlowTypeOfReference(node, type, defaultsToDeclaredType ? type : undefinedType);
if (strictNullChecks && !(type.flags & TypeFlags.Any) && !(getNullableKind(type) & TypeFlags.Undefined) && getNullableKind(flowType) & TypeFlags.Undefined) {