Skip to content

Commit b9fd53b

Browse files
Remove superficial usages of 'Array.from' (#3042)
1 parent 947ca28 commit b9fd53b

File tree

5 files changed

+4
-7
lines changed

5 files changed

+4
-7
lines changed

.flowconfig

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ export-renamed-default=error
3333
[options]
3434
all=true
3535
module.use_strict=true
36-
babel_loose_array_spread=true
3736
experimental.const_params=true
3837
include_warnings=true
3938
no_flowlib=true

src/__testUtils__/__tests__/genFuzzStrings-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function expectFuzzStrings(options: {|
77
allowedChars: Array<string>,
88
maxLength: number,
99
|}) {
10-
return expect(Array.from(genFuzzStrings(options)));
10+
return expect([...genFuzzStrings(options)]);
1111
}
1212

1313
describe('genFuzzStrings', () => {

src/type/schema.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ export class GraphQLSchema {
203203
// Keep track of all implementations by interface name.
204204
this._implementationsMap = Object.create(null);
205205

206-
for (const namedType of Array.from(allReferencedTypes)) {
206+
for (const namedType of allReferencedTypes) {
207207
if (namedType == null) {
208208
continue;
209209
}

src/utilities/astFromValue.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ export function astFromValue(value: mixed, type: GraphQLInputType): ?ValueNode {
6262
const itemType = type.ofType;
6363
if (isIterableObject(value)) {
6464
const valuesNodes = [];
65-
// Since we transpile for-of in loose mode it doesn't support iterators
66-
// and it's required to first convert iterable into array
67-
for (const item of Array.from(value)) {
65+
for (const item of value) {
6866
const itemNode = astFromValue(item, itemType);
6967
if (itemNode != null) {
7068
valuesNodes.push(itemNode);

src/validation/rules/FieldsOnCorrectTypeRule.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ function getSuggestedTypeNames(
105105
}
106106
}
107107

108-
return Array.from(suggestedTypes)
108+
return [...suggestedTypes]
109109
.sort((typeA, typeB) => {
110110
// Suggest both interface and object types based on how common they are.
111111
const usageCountDiff = usageCount[typeB.name] - usageCount[typeA.name];

0 commit comments

Comments
 (0)