Variables from different module declarations default to their declared type

This commit is contained in:
Anders Hejlsberg
2016-04-19 10:14:02 -07:00
parent d735b7acbf
commit c8bf6d821a
2 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -7936,7 +7936,7 @@ namespace ts {
const declaration = localOrExportSymbol.valueDeclaration;
const defaultsToDeclaredType = !strictNullChecks || !declaration ||
declaration.kind === SyntaxKind.Parameter || isInAmbientContext(declaration) ||
getContainingFunctionOrSourceFile(declaration) !== getContainingFunctionOrSourceFile(node);
getContainingFunctionOrModule(declaration) !== getContainingFunctionOrModule(node);
if (defaultsToDeclaredType && !(type.flags & TypeFlags.Narrowable)) {
return type;
}
+3 -3
View File
@@ -840,11 +840,11 @@ namespace ts {
}
}
export function getContainingFunctionOrSourceFile(node: Node): FunctionLikeDeclaration | SourceFile {
export function getContainingFunctionOrModule(node: Node): Node {
while (true) {
node = node.parent;
if (isFunctionLike(node) || node.kind === SyntaxKind.SourceFile) {
return <FunctionLikeDeclaration | SourceFile>node;
if (isFunctionLike(node) || node.kind === SyntaxKind.ModuleDeclaration || node.kind === SyntaxKind.SourceFile) {
return node;
}
}
}