@@ -93,7 +93,7 @@ export default class Store extends EventEmitter<{|
9393 // Map of ID to number of recorded error and warning message IDs.
9494 _errorsAndWarnings: Map <
9595 number ,
96- { errors : number , warnings : number } ,
96+ { | errorCount : number , warningCount : number | } ,
9797 > = new Map ( ) ;
9898
9999 // At least one of the injected renderers contains (DEV only) owner metadata.
@@ -490,15 +490,7 @@ export default class Store extends EventEmitter<{|
490490 getErrorAndWarningCountForElementID (
491491 id : number ,
492492 ) : { | errorCount : number , warningCount : number | } {
493- const map = this . _errorsAndWarnings . get ( id ) ;
494- if ( map != null ) {
495- return {
496- errorCount : map . errors ,
497- warningCount : map . warnings ,
498- } ;
499- } else {
500- return { errorCount : 0 , warningCount : 0 } ;
501- }
493+ return this . _errorsAndWarnings . get ( id ) || { errorCount : 0 , warningCount : 0 } ;
502494 }
503495
504496 getIndexOfElementID ( id : number ) : number | null {
@@ -1071,16 +1063,13 @@ export default class Store extends EventEmitter<{|
10711063 break ;
10721064 case TREE_OPERATION_UPDATE_ERRORS_OR_WARNINGS :
10731065 const id = operations [ i + 1 ] ;
1074- const numErrors = operations [ i + 2 ] ;
1075- const numWarnings = operations [ i + 3 ] ;
1066+ const errorCount = operations [ i + 2 ] ;
1067+ const warningCount = operations [ i + 3 ] ;
10761068
10771069 i += 4 ;
10781070
1079- if ( numErrors > 0 || numWarnings > 0 ) {
1080- this . _errorsAndWarnings . set ( id , {
1081- errors : numErrors ,
1082- warnings : numWarnings ,
1083- } ) ;
1071+ if ( errorCount > 0 || warningCount > 0 ) {
1072+ this . _errorsAndWarnings . set ( id , { errorCount, warningCount} ) ;
10841073 } else if ( this . _errorsAndWarnings . has ( id ) ) {
10851074 this . _errorsAndWarnings . delete ( id ) ;
10861075 }
@@ -1097,9 +1086,9 @@ export default class Store extends EventEmitter<{|
10971086 let errorCount = 0 ;
10981087 let warningCount = 0 ;
10991088
1100- this . _errorsAndWarnings . forEach ( ( { errors , warnings } ) => {
1101- errorCount += errors ;
1102- warningCount += warnings ;
1089+ this . _errorsAndWarnings . forEach ( entry => {
1090+ errorCount += entry . errorCount ;
1091+ warningCount += entry . warningCount ;
11031092 } ) ;
11041093
11051094 this . _cachedErrorCount = errorCount ;
0 commit comments