@@ -388,12 +388,14 @@ namespace ts {
388
388
message = Diagnostics . Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations ;
389
389
}
390
390
391
- if ( symbol . declarations && symbol . declarations . length ) {
391
+ let multipleDefaultExports = false ;
392
+ if ( length ( symbol . declarations ) ) {
392
393
// If the current node is a default export of some sort, then check if
393
394
// there are any other default exports that we need to error on.
394
395
// We'll know whether we have other default exports depending on if `symbol` already has a declaration list set.
395
396
if ( isDefaultExport ) {
396
397
message = Diagnostics . A_module_cannot_have_multiple_default_exports ;
398
+ multipleDefaultExports = true ;
397
399
}
398
400
else {
399
401
// 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 {
403
405
if ( symbol . declarations && symbol . declarations . length &&
404
406
( node . kind === SyntaxKind . ExportAssignment && ! ( < ExportAssignment > node ) . isExportEquals ) ) {
405
407
message = Diagnostics . A_module_cannot_have_multiple_default_exports ;
408
+ multipleDefaultExports = true ;
406
409
}
407
410
}
408
411
}
@@ -413,7 +416,7 @@ namespace ts {
413
416
const declarationName = getNameOfDeclaration ( node ) || node ;
414
417
const diag = createDiagnosticForNode ( declarationName , message , getDisplayName ( node ) )
415
418
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
417
420
) ;
418
421
419
422
symbol = createSymbol ( SymbolFlags . None , name ) ;
0 commit comments