@@ -12,6 +12,7 @@ import type {DOMTopLevelEventType} from 'legacy-events/TopLevelEventTypes';
12
12
import type { EventSystemFlags } from 'legacy-events/EventSystemFlags' ;
13
13
import type { Fiber } from 'react-reconciler/src/ReactFiber' ;
14
14
import type { PluginModule } from 'legacy-events/PluginModuleType' ;
15
+ import type { ReactSyntheticEvent } from 'legacy-events/ReactSyntheticEventType' ;
15
16
16
17
import { registrationNameDependencies } from 'legacy-events/EventPluginRegistry' ;
17
18
import { batchedEventUpdates } from 'legacy-events/ReactGenericBatching' ;
@@ -102,11 +103,11 @@ function dispatchEventsForPlugins(
102
103
rootContainer : Element | Document ,
103
104
) : void {
104
105
const nativeEventTarget = getEventTarget ( nativeEvent ) ;
105
- const syntheticEvents = [ ] ;
106
+ const syntheticEvents : Array < ReactSyntheticEvent > = [ ] ;
106
107
107
108
for ( let i = 0 ; i < plugins . length ; i ++ ) {
108
109
const possiblePlugin : PluginModule < AnyNativeEvent > = plugins [ i ] ;
109
- if ( possiblePlugin ) {
110
+ if ( possiblePlugin !== undefined ) {
110
111
const extractedEvents = possiblePlugin . extractEvents (
111
112
topLevelType ,
112
113
targetInst ,
@@ -115,12 +116,13 @@ function dispatchEventsForPlugins(
115
116
eventSystemFlags ,
116
117
rootContainer ,
117
118
) ;
118
- if ( extractedEvents ) {
119
- if ( isArray ( extractedEvents ) ) {
120
- syntheticEvents . push ( ...( extractedEvents : any ) ) ;
121
- } else {
122
- syntheticEvents . push ( extractedEvents ) ;
123
- }
119
+ if ( isArray ( extractedEvents ) ) {
120
+ // Flow complains about @@iterator being missing in ReactSyntheticEvent,
121
+ // so we cast to avoid the Flow error.
122
+ const arrOfExtractedEvents = ( ( extractedEvents : any ) : Array < ReactSyntheticEvent > ) ;
123
+ syntheticEvents . push ( ...arrOfExtractedEvents ) ;
124
+ } else if ( extractedEvents != null ) {
125
+ syntheticEvents . push ( extractedEvents ) ;
124
126
}
125
127
}
126
128
}
0 commit comments