|
7 | 7 | * @flow |
8 | 8 | */ |
9 | 9 |
|
10 | | -function invokeGuardedCallbackProd<A, B, C, D, E, F, Context>( |
| 10 | +function invokeGuardedCallbackProd<Args: Array<mixed>, Context>( |
11 | 11 | name: string | null, |
12 | | - func: (a: A, b: B, c: C, d: D, e: E, f: F) => mixed, |
| 12 | + func: (...Args) => mixed, |
13 | 13 | context: Context, |
14 | | - a: A, |
15 | | - b: B, |
16 | | - c: C, |
17 | | - d: D, |
18 | | - e: E, |
19 | | - f: F, |
20 | | -) { |
| 14 | +): void { |
21 | 15 | const funcArgs = Array.prototype.slice.call(arguments, 3); |
22 | 16 | try { |
| 17 | + // $FlowFixMe[incompatible-call] Flow doesn't understand the arguments splicing. |
23 | 18 | func.apply(context, funcArgs); |
24 | 19 | } catch (error) { |
25 | 20 | this.onError(error); |
26 | 21 | } |
27 | 22 | } |
28 | 23 |
|
29 | | -let invokeGuardedCallbackImpl = invokeGuardedCallbackProd; |
| 24 | +let invokeGuardedCallbackImpl: <Args: Array<mixed>, Context>( |
| 25 | + name: string | null, |
| 26 | + func: (...Args) => mixed, |
| 27 | + context: Context, |
| 28 | +) => void = invokeGuardedCallbackProd; |
30 | 29 |
|
31 | 30 | if (__DEV__) { |
32 | 31 | // In DEV mode, we swap out invokeGuardedCallback for a special version |
@@ -59,24 +58,9 @@ if (__DEV__) { |
59 | 58 | const fakeNode = document.createElement('react'); |
60 | 59 |
|
61 | 60 | invokeGuardedCallbackImpl = function invokeGuardedCallbackDev< |
62 | | - A, |
63 | | - B, |
64 | | - C, |
65 | | - D, |
66 | | - E, |
67 | | - F, |
| 61 | + Args: Array<mixed>, |
68 | 62 | Context, |
69 | | - >( |
70 | | - name: string | null, |
71 | | - func: (a: A, b: B, c: C, d: D, e: E, f: F) => mixed, |
72 | | - context: Context, |
73 | | - a: A, |
74 | | - b: B, |
75 | | - c: C, |
76 | | - d: D, |
77 | | - e: E, |
78 | | - f: F, |
79 | | - ) { |
| 63 | + >(name: string | null, func: (...Args) => mixed, context: Context): void { |
80 | 64 | // If document doesn't exist we know for sure we will crash in this method |
81 | 65 | // when we call document.createEvent(). However this can cause confusing |
82 | 66 | // errors: https://github.com/facebook/create-react-app/issues/3482 |
@@ -142,6 +126,7 @@ if (__DEV__) { |
142 | 126 | function callCallback() { |
143 | 127 | didCall = true; |
144 | 128 | restoreAfterDispatch(); |
| 129 | + // $FlowFixMe[incompatible-call] Flow doesn't understand the arguments splicing. |
145 | 130 | func.apply(context, funcArgs); |
146 | 131 | didError = false; |
147 | 132 | } |
|
0 commit comments