From bd08e882fa122741e6d95dd66c2d0369db94ce68 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 29 Apr 2016 13:57:28 -0700 Subject: [PATCH] Correct handling of destructuring parameters 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 6cedb78686d..57490019f1f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -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) {