@samitouri / QOS-React / commits / 54cbe29262

Fix Flow errors in Event Plugins (#7698)

Due to a typo in PR#7667 where I put 'DispatchConfig' when the type was 'EventTypes', there were some flow errors being thrown. Then PR#7642 fixed a bug in SimpleEventPlugin and added some untyped methods, which threw more flow errors. Last, while fixing this, I fixed two eslint errors in the SimpleEventPlugin test.

Flarnie Marchan committed Sep 10, 2016 at 16:44 UTC 54cbe2926249b0d8c1da17b6ecb19484cc409df1
5 files changed +16 -8
src/renderers/dom/client/eventPlugins/SimpleEventPlugin.js
+5 -2
@@ -37,7 +37,10 @@ import type {
37 ReactSyntheticEvent,
38 } from 'ReactSyntheticEventType';
39 import type {ReactInstance} from 'ReactInstanceType';
40 -import type {PluginModule} from 'PluginModuleType';
40 +import type {
41 + EventTypes,
42 + PluginModule,
43 +} from 'PluginModuleType';
44
45 /**
46 * Turns
@@ -57,7 +60,7 @@ import type {PluginModule} from 'PluginModuleType';
60 * 'topAbort': { sameConfig }
61 * };
62 */
60 -var eventTypes: {[key: string]: DispatchConfig} = {};
63 +var eventTypes: EventTypes = {};
64 var topLevelEventsToDispatchConfig: {[key: TopLevelTypes]: DispatchConfig} = {};
65 [
66 'abort',
src/renderers/dom/client/eventPlugins/TapEventPlugin.js
+5 -3
@@ -21,8 +21,10 @@ var ViewportMetrics = require('ViewportMetrics');
21 var isStartish = EventPluginUtils.isStartish;
22 var isEndish = EventPluginUtils.isEndish;
23
24 -import type {DispatchConfig} from 'ReactSyntheticEventType';
25 -import type {PluginModule} from 'PluginModuleType';
24 +import type {
25 + EventTypes,
26 + PluginModule,
27 +} from 'PluginModuleType';
28 import type {ReactInstance} from 'ReactInstanceType';
29 import type {TopLevelTypes} from 'EventConstants';
30
@@ -109,7 +111,7 @@ var dependencies = [
111 'topMouseUp',
112 ].concat(touchEvents);
113
112 -var eventTypes: DispatchConfig = {
114 +var eventTypes: EventTypes = {
115 touchTap: {
116 phasedRegistrationNames: {
117 bubbled: 'onTouchTap',
src/renderers/dom/client/eventPlugins/__tests__/SimpleEventPlugin-test.js
+2 -2
@@ -128,7 +128,7 @@ describe('SimpleEventPlugin', function() {
128 onClick.mockClear();
129 });
130
131 - it ('does not add a local click to interactive elements', function() {
131 + it('does not add a local click to interactive elements', function() {
132 var container = document.createElement('div');
133
134 ReactDOM.render(<button onClick={ onClick }></button>, container);
@@ -140,7 +140,7 @@ describe('SimpleEventPlugin', function() {
140 expect(onClick.mock.calls.length).toBe(0);
141 });
142
143 - it ('adds a local click listener to non-interactive elements', function() {
143 + it('adds a local click listener to non-interactive elements', function() {
144 var container = document.createElement('div');
145
146 ReactDOM.render(<div onClick={ onClick }></div>, container);
src/renderers/shared/stack/event/PluginModuleType.js
+1 -1
@@ -18,7 +18,7 @@ import type {
18 ReactSyntheticEvent,
19 } from 'ReactSyntheticEventType';
20
21 -type EventTypes = {[key: string]: DispatchConfig};
21 +export type EventTypes = {[key: string]: DispatchConfig};
22
23 export type AnyNativeEvent =
24 Event |
src/renderers/shared/stack/reconciler/ReactInstanceType.js
+3
@@ -30,6 +30,9 @@ export type ReactInstance = {
30 getPublicInstance: any,
31 _rootNodeID: number,
32
33 + // ReactDOMComponent
34 + _tag: string,
35 +
36 // instantiateReactComponent
37 _mountIndex: number,
38 _mountImage: any,