@@ -349,23 +349,26 @@ namespace ts {
349349 ? Diagnostics . Cannot_redeclare_block_scoped_variable_0
350350 : Diagnostics . Duplicate_identifier_0 ;
351351
352- // If the current node is a default export of some sort, then check if
353- // there are any other default exports that we need to error on.
354- // We'll know whether we have other default exports depending on if `symbol` already has a declaration list set.
355- if ( isDefaultExport && symbol . declarations ) {
356- message = Diagnostics . A_module_cannot_have_multiple_default_exports ;
357- }
358- else {
359- // This is to properly report an error in the case "export default { }" is after export default of class declaration or function declaration.
360- forEach ( symbol . declarations , declaration => {
361- // Error on multiple export default in the following case:
362- // 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default
363- // 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers)
364- if ( ( declaration . flags & NodeFlags . Default ) ||
365- ( declaration . kind === SyntaxKind . ExportAssignment && ! ( < ExportAssignment > node ) . isExportEquals ) ) {
366- message = Diagnostics . A_module_cannot_have_multiple_default_exports ;
352+ if ( symbol . declarations && symbol . declarations . length ) {
353+ // If the current node is a default export of some sort, then check if
354+ // there are any other default exports that we need to error on.
355+ // We'll know whether we have other default exports depending on if `symbol` already has a declaration list set.
356+ if ( isDefaultExport ) {
357+ message = Diagnostics . A_module_cannot_have_multiple_default_exports ;
358+ }
359+ else {
360+ // This is to properly report an error in the case "export default { }" is after export default of class declaration or function declaration.
361+ for ( const declaration of symbol . declarations ) {
362+ // Error on multiple export default in the following case:
363+ // 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default
364+ // 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers)
365+ if ( ( declaration . flags & NodeFlags . Default ) ||
366+ ( declaration . kind === SyntaxKind . ExportAssignment && ! ( < ExportAssignment > node ) . isExportEquals ) ) {
367+ message = Diagnostics . A_module_cannot_have_multiple_default_exports ;
368+ break ;
369+ }
367370 }
368- } ) ;
371+ }
369372 }
370373
371374 forEach ( symbol . declarations , declaration => {
0 commit comments