Prevent collision of imported type with exported declarations in current module (#31231)

* check for exported type name for conflict

* refactor baseline tests for import/export name collision
This commit is contained in:
Collins Abitekaniza
2019-09-27 17:55:05 +03:00
committed by Andrew Branch
parent e72937deff
commit c0573c59c9
11 changed files with 28 additions and 11 deletions

View File

@@ -31965,7 +31965,7 @@ namespace ts {
}
function checkAliasSymbol(node: ImportEqualsDeclaration | ImportClause | NamespaceImport | ImportSpecifier | ExportSpecifier) {
const symbol = getSymbolOfNode(node);
let symbol = getSymbolOfNode(node);
const target = resolveAlias(symbol);
const shouldSkipWithJSExpandoTargets = symbol.flags & SymbolFlags.Assignment;
@@ -31976,6 +31976,7 @@ namespace ts {
// Based on symbol.flags we can compute a set of excluded meanings (meaning that resolved alias should not have,
// otherwise it will conflict with some local declaration). Note that in addition to normal flags we include matching SymbolFlags.Export*
// in order to prevent collisions with declarations that were exported from the current module (they still contribute to local names).
symbol = getMergedSymbol(symbol.exportSymbol || symbol);
const excludedMeanings =
(symbol.flags & (SymbolFlags.Value | SymbolFlags.ExportValue) ? SymbolFlags.Value : 0) |
(symbol.flags & SymbolFlags.Type ? SymbolFlags.Type : 0) |