Skip to content

Commit 2a0dcd9

Browse files
Improve Flow typing for 'memoize3' (#1994)
1 parent e6d2c5a commit 2a0dcd9

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/jsutils/memoize3.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33
/**
44
* Memoizes the provided three-argument function.
55
*/
6-
export default function memoize3<T: (a1: any, a2: any, a3: any) => any>(
7-
fn: T,
8-
): T {
6+
export default function memoize3<
7+
A1: { ... } | $ReadOnlyArray<mixed>,
8+
A2: { ... } | $ReadOnlyArray<mixed>,
9+
A3: { ... } | $ReadOnlyArray<mixed>,
10+
R: mixed,
11+
>(fn: (A1, A2, A3) => R): (A1, A2, A3) => R {
912
let cache0;
13+
1014
function memoized(a1, a2, a3) {
1115
if (!cache0) {
1216
cache0 = new WeakMap();
@@ -33,5 +37,6 @@ export default function memoize3<T: (a1: any, a2: any, a3: any) => any>(
3337
cache2.set(a3, newValue);
3438
return newValue;
3539
}
36-
return (memoized: any);
40+
41+
return memoized;
3742
}

0 commit comments

Comments
 (0)