@@ -1314,7 +1314,6 @@ namespace ts {
13141314 }
13151315
13161316 switch ( node . kind ) {
1317- case SyntaxKind . SourceFile :
13181317 case SyntaxKind . PropertySignature :
13191318 case SyntaxKind . PropertyDeclaration :
13201319 case SyntaxKind . MethodSignature :
@@ -1357,27 +1356,23 @@ namespace ts {
13571356 return false ;
13581357 }
13591358
1360- function forEachTopLevelDeclaration ( node : Node , action : ( node : Node ) => void ) : void {
1359+ function forEachTopLevelDeclaration < T > ( node : Node , action : ( node : Node ) => T ) : T {
13611360 switch ( node . kind ) {
13621361 case SyntaxKind . SourceFile :
1363- forEach ( ( < SourceFile > node ) . statements , action ) ;
1364- break ;
1362+ return forEach ( ( < SourceFile > node ) . statements , action ) ;
13651363 case SyntaxKind . InterfaceDeclaration :
13661364 case SyntaxKind . EnumDeclaration :
13671365 case SyntaxKind . ClassDeclaration :
1368- forEach ( ( < InterfaceDeclaration | EnumDeclaration | ClassDeclaration > node ) . members , action ) ;
1369- break ;
1366+ return forEach ( ( < InterfaceDeclaration | EnumDeclaration | ClassDeclaration > node ) . members , action ) ;
13701367 case SyntaxKind . VariableStatement :
1371- forEach ( ( < VariableStatement > node ) . declarationList . declarations , action ) ;
1372- break ;
1368+ return forEach ( ( < VariableStatement > node ) . declarationList . declarations , action ) ;
13731369 case SyntaxKind . ModuleDeclaration :
13741370 if ( ( < ModuleDeclaration > node ) . body . kind === SyntaxKind . ModuleBlock ) {
1375- forEach ( ( < ModuleBlock > ( < ModuleDeclaration > node ) . body ) . statements , action ) ;
1371+ return forEach ( ( < ModuleBlock > ( < ModuleDeclaration > node ) . body ) . statements , action ) ;
13761372 }
13771373 else {
1378- action ( ( < ModuleDeclaration > node ) . body ) ;
1374+ return action ( ( < ModuleDeclaration > node ) . body ) ;
13791375 }
1380- break ;
13811376 }
13821377 }
13831378
@@ -1410,15 +1405,10 @@ namespace ts {
14101405 }
14111406
14121407 let links = getNodeLinks ( node ) ;
1413- if ( typeof links . hasExportDeclarations === "undefined" ) {
1414- let foundExportDeclarations = false ;
1415- /// TODO: swithc this to return a value if truthy
1416- forEachTopLevelDeclaration ( node , n => {
1417- if ( n . kind === SyntaxKind . ExportAssignment || n . kind === SyntaxKind . ExportDeclaration ) {
1418- foundExportDeclarations = true ;
1419- }
1408+ if ( links . hasExportDeclarations === undefined ) {
1409+ links . hasExportDeclarations = ! ! forEachTopLevelDeclaration ( node , n => {
1410+ return ( n . kind === SyntaxKind . ExportAssignment || n . kind === SyntaxKind . ExportDeclaration ) ;
14201411 } ) ;
1421- links . hasExportDeclarations = foundExportDeclarations
14221412 }
14231413 return links . hasExportDeclarations ;
14241414 }
0 commit comments