fix issue where duplicate default exports aren't detected (#46871)

* fix issue where duplicate default exports aren't detected when there's an interface

* accept baseline change

* add `exportDefaultInterfaceClassAndValue` test

* add more tests for multiple default exports

* add two interfaces test

Co-authored-by: DetachHead <detachhead@users.noreply.github.com>
This commit is contained in:
DetachHead
2022-02-17 13:17:31 -08:00
committed by GitHub
co-authored by DetachHead
parent fb1066e5d9
commit 092018bd7e
50 changed files with 667 additions and 3 deletions
+2 -2
View File
@@ -40449,10 +40449,10 @@ namespace ts {
}
// ECMA262: 15.2.1.1 It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries.
// (TS Exceptions: namespaces, function overloads, enums, and interfaces)
if (flags & (SymbolFlags.Namespace | SymbolFlags.Interface | SymbolFlags.Enum)) {
if (flags & (SymbolFlags.Namespace | SymbolFlags.Enum)) {
return;
}
const exportedDeclarationsCount = countWhere(declarations, isNotOverloadAndNotAccessor);
const exportedDeclarationsCount = countWhere(declarations, and(isNotOverloadAndNotAccessor, not(isInterfaceDeclaration)));
if (flags & SymbolFlags.TypeAlias && exportedDeclarationsCount <= 2) {
// it is legal to merge type alias with other values
// so count should be either 1 (just type alias) or 2 (type alias + merged value)