Improved non-namespace overriding

Per @ahejlsberg's suggestion, only overwrite a namespace
`valueDeclaration` if the new declaration is not a namespace itself. This
means that if there are multiple namespace declarations, and nothing else,
`valueDeclaration` will be the first namespace declaration, not the last.
This commit is contained in:
Nathan Shively-Sanders
2015-10-11 15:33:17 -07:00
parent 9e8031cfc3
commit ec2eac53bf
2 changed files with 4 additions and 2 deletions

View File

@@ -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;
}

View File

@@ -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;
}