diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 57d610c931e..b33f0b95fa3 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -130,12 +130,14 @@ namespace ts { symbol.members = {}; } - if (symbolFlags & SymbolFlags.Value && - (!symbol.valueDeclaration || - (symbol.valueDeclaration.kind === SyntaxKind.ModuleDeclaration && node.kind !== SyntaxKind.ModuleDeclaration))) { - // other kinds of value declarations take precedence over modules - symbol.valueDeclaration = node; - } + if (symbolFlags & SymbolFlags.Value) { + const valueDeclaration = symbol.valueDeclaration; + if (!valueDeclaration || + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === SyntaxKind.ModuleDeclaration)) { + // other kinds of value declarations take precedence over modules + symbol.valueDeclaration = node; + } + } } // Should not be called on a declaration with a computed property name,