Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove superficial usages of 'Array.from' #3042

Merged
merged 1 commit into from Apr 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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