From b9fd53bfc23124c26954e25de40ebb3b27bf9367 Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Thu, 15 Apr 2021 23:49:25 +0300 Subject: [PATCH] Remove superficial usages of 'Array.from' (#3042) --- .flowconfig | 1 - src/__testUtils__/__tests__/genFuzzStrings-test.js | 2 +- src/type/schema.js | 2 +- src/utilities/astFromValue.js | 4 +--- src/validation/rules/FieldsOnCorrectTypeRule.js | 2 +- 5 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.flowconfig b/.flowconfig index d12756c5b0..0282b9608e 100644 --- a/.flowconfig +++ b/.flowconfig @@ -33,7 +33,6 @@ export-renamed-default=error [options] all=true module.use_strict=true -babel_loose_array_spread=true experimental.const_params=true include_warnings=true no_flowlib=true diff --git a/src/__testUtils__/__tests__/genFuzzStrings-test.js b/src/__testUtils__/__tests__/genFuzzStrings-test.js index 70f267353b..c329123717 100644 --- a/src/__testUtils__/__tests__/genFuzzStrings-test.js +++ b/src/__testUtils__/__tests__/genFuzzStrings-test.js @@ -7,7 +7,7 @@ function expectFuzzStrings(options: {| allowedChars: Array, maxLength: number, |}) { - return expect(Array.from(genFuzzStrings(options))); + return expect([...genFuzzStrings(options)]); } describe('genFuzzStrings', () => { diff --git a/src/type/schema.js b/src/type/schema.js index be67ffd270..3f9c34a951 100644 --- a/src/type/schema.js +++ b/src/type/schema.js @@ -203,7 +203,7 @@ export class GraphQLSchema { // Keep track of all implementations by interface name. this._implementationsMap = Object.create(null); - for (const namedType of Array.from(allReferencedTypes)) { + for (const namedType of allReferencedTypes) { if (namedType == null) { continue; } diff --git a/src/utilities/astFromValue.js b/src/utilities/astFromValue.js index c962f54fb3..5621659f73 100644 --- a/src/utilities/astFromValue.js +++ b/src/utilities/astFromValue.js @@ -62,9 +62,7 @@ export function astFromValue(value: mixed, type: GraphQLInputType): ?ValueNode { const itemType = type.ofType; if (isIterableObject(value)) { const valuesNodes = []; - // Since we transpile for-of in loose mode it doesn't support iterators - // and it's required to first convert iterable into array - for (const item of Array.from(value)) { + for (const item of value) { const itemNode = astFromValue(item, itemType); if (itemNode != null) { valuesNodes.push(itemNode); diff --git a/src/validation/rules/FieldsOnCorrectTypeRule.js b/src/validation/rules/FieldsOnCorrectTypeRule.js index 6a1789b60f..d2a37bb75e 100644 --- a/src/validation/rules/FieldsOnCorrectTypeRule.js +++ b/src/validation/rules/FieldsOnCorrectTypeRule.js @@ -105,7 +105,7 @@ function getSuggestedTypeNames( } } - return Array.from(suggestedTypes) + return [...suggestedTypes] .sort((typeA, typeB) => { // Suggest both interface and object types based on how common they are. const usageCountDiff = usageCount[typeB.name] - usageCount[typeA.name];