From eb085199b56f31576dc9ee63a2876a3ebdc958f4 Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Tue, 27 Aug 2019 15:52:39 +0300 Subject: [PATCH] Flow: fix errors in 'flatMap.js' on old Flow versions Fixes #2136 --- src/polyfills/flatMap.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/polyfills/flatMap.js b/src/polyfills/flatMap.js index b2402dfa59..96c038d1c1 100644 --- a/src/polyfills/flatMap.js +++ b/src/polyfills/flatMap.js @@ -5,11 +5,14 @@ declare function flatMap( fn: (item: T, index: number) => $ReadOnlyArray | U, ): Array; +// 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 = [];