Skip to content

Commit 8ab6524

Browse files
Flow: fix errors in 'flatMap.js' on old Flow versions (#2137)
Fixes #2136
1 parent 3e9c191 commit 8ab6524

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/polyfills/flatMap.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@ declare function flatMap<T, U>(
55
fn: (item: T, index: number) => $ReadOnlyArray<U> | U,
66
): Array<U>;
77

8+
// Workaround to make older Flow versions happy
9+
const flatMapMethod = (Array.prototype: any).flatMap;
10+
811
/* eslint-disable no-redeclare */
912
// $FlowFixMe
10-
const flatMap = Array.prototype.flatMap
13+
const flatMap = flatMapMethod
1114
? function(list, fn) {
12-
return Array.prototype.flatMap.call(list, fn);
15+
return flatMapMethod.call(list, fn);
1316
}
1417
: function(list, fn) {
1518
let result = [];

0 commit comments

Comments
 (0)