diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 813a7e2cd43..57d610c931e 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -131,7 +131,8 @@ namespace ts { } if (symbolFlags & SymbolFlags.Value && - (!symbol.valueDeclaration || symbol.valueDeclaration.kind === SyntaxKind.ModuleDeclaration)) { + (!symbol.valueDeclaration || + (symbol.valueDeclaration.kind === SyntaxKind.ModuleDeclaration && node.kind !== SyntaxKind.ModuleDeclaration))) { // other kinds of value declarations take precedence over modules symbol.valueDeclaration = node; } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d22266d951f..6b3ddf9da32 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -294,7 +294,8 @@ namespace ts { } target.flags |= source.flags; if (source.valueDeclaration && - (!target.valueDeclaration || target.valueDeclaration.kind === SyntaxKind.ModuleDeclaration)) { + (!target.valueDeclaration || + (target.valueDeclaration.kind === SyntaxKind.ModuleDeclaration && source.valueDeclaration.kind !== SyntaxKind.ModuleDeclaration))) { // other kinds of value declarations take precedence over modules target.valueDeclaration = source.valueDeclaration; }