Skip to content

Commit

Permalink
Remove superficial usages of 'Array.from' (#3042)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed Apr 15, 2021
1 parent 947ca28 commit b9fd53b
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 7 deletions.
1 change: 0 additions & 1 deletion .flowconfig
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/__testUtils__/__tests__/genFuzzStrings-test.js
Expand Up @@ -7,7 +7,7 @@ function expectFuzzStrings(options: {|
allowedChars: Array<string>,
maxLength: number,
|}) {
return expect(Array.from(genFuzzStrings(options)));
return expect([...genFuzzStrings(options)]);
}

describe('genFuzzStrings', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/type/schema.js
Expand Up @@ -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;
}
Expand Down
4 changes: 1 addition & 3 deletions src/utilities/astFromValue.js
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/validation/rules/FieldsOnCorrectTypeRule.js
Expand Up @@ -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];
Expand Down

0 comments on commit b9fd53b

Please sign in to comment.