@@ -12,6 +12,7 @@ import type {DOMTopLevelEventType} from 'legacy-events/TopLevelEventTypes';
1212import type { EventSystemFlags } from 'legacy-events/EventSystemFlags' ;
1313import type { Fiber } from 'react-reconciler/src/ReactFiber' ;
1414import type { PluginModule } from 'legacy-events/PluginModuleType' ;
15+ import type { ReactSyntheticEvent } from 'legacy-events/ReactSyntheticEventType' ;
1516
1617import { registrationNameDependencies } from 'legacy-events/EventPluginRegistry' ;
1718import { batchedEventUpdates } from 'legacy-events/ReactGenericBatching' ;
@@ -102,11 +103,11 @@ function dispatchEventsForPlugins(
102103 rootContainer : Element | Document ,
103104) : void {
104105 const nativeEventTarget = getEventTarget ( nativeEvent ) ;
105- const syntheticEvents = [ ] ;
106+ const syntheticEvents : Array < ReactSyntheticEvent > = [ ] ;
106107
107108 for ( let i = 0 ; i < plugins . length ; i ++ ) {
108109 const possiblePlugin : PluginModule < AnyNativeEvent > = plugins [ i ] ;
109- if ( possiblePlugin ) {
110+ if ( possiblePlugin !== undefined ) {
110111 const extractedEvents = possiblePlugin . extractEvents (
111112 topLevelType ,
112113 targetInst ,
@@ -115,12 +116,13 @@ function dispatchEventsForPlugins(
115116 eventSystemFlags ,
116117 rootContainer ,
117118 ) ;
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 ) ;
124126 }
125127 }
126128 }
0 commit comments