@@ -93,7 +93,7 @@ export default class Store extends EventEmitter<{|
93
93
// Map of ID to number of recorded error and warning message IDs.
94
94
_errorsAndWarnings: Map <
95
95
number ,
96
- { errors : number , warnings : number } ,
96
+ { | errorCount : number , warningCount : number | } ,
97
97
> = new Map ( ) ;
98
98
99
99
// At least one of the injected renderers contains (DEV only) owner metadata.
@@ -490,15 +490,7 @@ export default class Store extends EventEmitter<{|
490
490
getErrorAndWarningCountForElementID (
491
491
id : number ,
492
492
) : { | 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 } ;
502
494
}
503
495
504
496
getIndexOfElementID ( id : number ) : number | null {
@@ -1071,16 +1063,13 @@ export default class Store extends EventEmitter<{|
1071
1063
break ;
1072
1064
case TREE_OPERATION_UPDATE_ERRORS_OR_WARNINGS :
1073
1065
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 ] ;
1076
1068
1077
1069
i += 4 ;
1078
1070
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} ) ;
1084
1073
} else if ( this . _errorsAndWarnings . has ( id ) ) {
1085
1074
this . _errorsAndWarnings . delete ( id ) ;
1086
1075
}
@@ -1097,9 +1086,9 @@ export default class Store extends EventEmitter<{|
1097
1086
let errorCount = 0 ;
1098
1087
let warningCount = 0 ;
1099
1088
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 ;
1103
1092
} ) ;
1104
1093
1105
1094
this . _cachedErrorCount = errorCount ;
0 commit comments