mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 11:24:29 -05:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user