@samitouri / QOS-React-2 / commits / 395888435b

Cleanup ReactErrorUtils (#7610)

This cleans up the Flow annotations and brings the implementations in line.

Paul O’Shannessy committed Aug 29, 2016 at 20:44 UTC 395888435b44b18b339f7626df5c472335601a11
1 file changed +8 -11
src/renderers/shared/utils/ReactErrorUtils.js
+8 -11
@@ -22,19 +22,17 @@ var caughtError = null;
22 * @param {*} a First argument
23 * @param {*} b Second argument
24 */
25 -function invokeGuardedCallback<A, B, C>(
25 +function invokeGuardedCallback<A>(
26 name: string,
27 - func: (a: A, b: B) => C,
27 + func: (a: A) => void,
28 a: A,
29 - b: B,
30 -): ?C {
29 +): void {
30 try {
32 - return func(a, b);
31 + func(a);
32 } catch (x) {
33 if (caughtError === null) {
34 caughtError = x;
35 }
37 - return undefined;
36 }
37 }
38
@@ -70,13 +68,12 @@ if (__DEV__) {
68 typeof document !== 'undefined' &&
69 typeof document.createEvent === 'function') {
70 var fakeNode = document.createElement('react');
73 - ReactErrorUtils.invokeGuardedCallback = function<A, B, C>(
71 + ReactErrorUtils.invokeGuardedCallback = function<A>(
72 name: string,
75 - func: (a: A, b: B) => C,
73 + func: (a: A) => void,
74 a: A,
77 - b: B,
78 - ): ?C {
79 - var boundFunc = func.bind(null, a, b);
75 + ): void {
76 + var boundFunc = func.bind(null, a);
77 var evtType = `react-${name}`;
78 fakeNode.addEventListener(evtType, boundFunc, false);
79 var evt = document.createEvent('Event');