diff --git a/.flowconfig b/.flowconfig index 8a7e861c5c..28625456dc 100644 --- a/.flowconfig +++ b/.flowconfig @@ -12,7 +12,7 @@ .*/node_modules/react-tools/src/vendor/core/ExecutionEnvironment.js .*/node_modules/react-tools/src/browser/.* .*/node_modules/react-tools/src/core/ReactInstanceHandles.js -.*/node_modules/react-tools/src/event/.* +.*/node_modules/react-tools/src/event/EventPropagators.js # Ignore jest .*/react-native/node_modules/jest-cli/.* diff --git a/Libraries/ReactIOS/ReactIOSEventEmitter.js b/Libraries/ReactIOS/ReactIOSEventEmitter.js index fa4afae61e..017a0fb0a4 100644 --- a/Libraries/ReactIOS/ReactIOSEventEmitter.js +++ b/Libraries/ReactIOS/ReactIOSEventEmitter.js @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. * * @providesModule ReactIOSEventEmitter - * @typechecks static-only + * @flow */ "use strict"; @@ -57,21 +57,27 @@ var touchSubsequence = function(touches, indices) { * @param {Array} indices Indices to remove from `touches`. * @return {Array} Subsequence of removed touch objects. */ -var removeTouchesAtIndices = function(touches, indices) { +var removeTouchesAtIndices = function( + touches: Array, + indices: Array +): Array { var rippedOut = []; + // use an unsafe downcast to alias to nullable elements, + // so we can delete and then compact. + var temp: Array = (touches: Array); for (var i = 0; i < indices.length; i++) { var index = indices[i]; rippedOut.push(touches[index]); - touches[index] = null; + temp[index] = null; } var fillAt = 0; - for (var j = 0; j < touches.length; j++) { - var cur = touches[j]; + for (var j = 0; j < temp.length; j++) { + var cur = temp[j]; if (cur !== null) { - touches[fillAt++] = cur; + temp[fillAt++] = cur; } } - touches.length = fillAt; + temp.length = fillAt; return rippedOut; }; @@ -106,7 +112,11 @@ var ReactIOSEventEmitter = merge(ReactEventEmitterMixin, { * @param {TopLevelType} topLevelType Top level type of event. * @param {object} nativeEventParam Object passed from native. */ - _receiveRootNodeIDEvent: function(rootNodeID, topLevelType, nativeEventParam) { + _receiveRootNodeIDEvent: function( + rootNodeID: ?string, + topLevelType: string, + nativeEventParam: Object + ) { var nativeEvent = nativeEventParam || EMPTY_NATIVE_EVENT; ReactIOSEventEmitter.handleTopLevel( topLevelType, @@ -123,7 +133,11 @@ var ReactIOSEventEmitter = merge(ReactEventEmitterMixin, { * @param {TopLevelType} topLevelType Top level type of event. * @param {object} nativeEventParam Object passed from native. */ - receiveEvent: function(tag, topLevelType, nativeEventParam) { + receiveEvent: function( + tag: number, + topLevelType: string, + nativeEventParam: Object + ) { var rootNodeID = ReactIOSTagHandles.tagToRootNodeID[tag]; ReactIOSEventEmitter._receiveRootNodeIDEvent( rootNodeID, @@ -156,7 +170,11 @@ var ReactIOSEventEmitter = merge(ReactEventEmitterMixin, { * Web desktop polyfills only need to construct a fake touch event with * identifier 0, also abandoning traditional click handlers. */ - receiveTouches: function(eventTopLevelType, touches, changedIndices) { + receiveTouches: function( + eventTopLevelType: string, + touches: Array, + changedIndices: Array + ) { var changedTouches = eventTopLevelType === topLevelTypes.topTouchEnd || eventTopLevelType === topLevelTypes.topTouchCancel ?