@@ -388,12 +388,14 @@ namespace ts {
388388 message = Diagnostics . Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations ;
389389 }
390390
391- if ( symbol . declarations && symbol . declarations . length ) {
391+ let multipleDefaultExports = false ;
392+ if ( length ( symbol . declarations ) ) {
392393 // If the current node is a default export of some sort, then check if
393394 // there are any other default exports that we need to error on.
394395 // We'll know whether we have other default exports depending on if `symbol` already has a declaration list set.
395396 if ( isDefaultExport ) {
396397 message = Diagnostics . A_module_cannot_have_multiple_default_exports ;
398+ multipleDefaultExports = true ;
397399 }
398400 else {
399401 // This is to properly report an error in the case "export default { }" is after export default of class declaration or function declaration.
@@ -403,6 +405,7 @@ namespace ts {
403405 if ( symbol . declarations && symbol . declarations . length &&
404406 ( node . kind === SyntaxKind . ExportAssignment && ! ( < ExportAssignment > node ) . isExportEquals ) ) {
405407 message = Diagnostics . A_module_cannot_have_multiple_default_exports ;
408+ multipleDefaultExports = true ;
406409 }
407410 }
408411 }
@@ -413,7 +416,7 @@ namespace ts {
413416 const declarationName = getNameOfDeclaration ( node ) || node ;
414417 const diag = createDiagnosticForNode ( declarationName , message , getDisplayName ( node ) )
415418 file . bindDiagnostics . push (
416- isDefaultExport ? addRelatedInfo ( diag , createDiagnosticForNode ( declarationName , Diagnostics . This_export_conflicts_with_the_first ) ) : diag
419+ multipleDefaultExports ? addRelatedInfo ( diag , createDiagnosticForNode ( declarationName , Diagnostics . This_export_conflicts_with_the_first ) ) : diag
417420 ) ;
418421
419422 symbol = createSymbol ( SymbolFlags . None , name ) ;
0 commit comments