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