Skip to content

Commit

Permalink
Flow: fix errors in 'flatMap.js' on old Flow versions (#2137)
Browse files Browse the repository at this point in the history
Fixes #2136
  • Loading branch information
IvanGoncharov committed Aug 27, 2019
1 parent 3e9c191 commit 8ab6524
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/polyfills/flatMap.js
Expand Up @@ -5,11 +5,14 @@ declare function flatMap<T, U>(
fn: (item: T, index: number) => $ReadOnlyArray<U> | U,
): Array<U>;

// Workaround to make older Flow versions happy
const flatMapMethod = (Array.prototype: any).flatMap;

/* eslint-disable no-redeclare */
// $FlowFixMe
const flatMap = Array.prototype.flatMap
const flatMap = flatMapMethod
? function(list, fn) {
return Array.prototype.flatMap.call(list, fn);
return flatMapMethod.call(list, fn);
}
: function(list, fn) {
let result = [];
Expand Down

0 comments on commit 8ab6524

Please sign in to comment.