Skip to content

Commit

Permalink
Switch some of arguments from Array to $ReadOnlyArray (#2001)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov authored Jun 28, 2019
1 parent 27f695e commit 9b2e626
Show file tree
Hide file tree
Showing 13 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/execution/values.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type CoercedVariableValues = {|
*/
export function getVariableValues(
schema: GraphQLSchema,
varDefNodes: Array<VariableDefinitionNode>,
varDefNodes: $ReadOnlyArray<VariableDefinitionNode>,
inputs: ObjMap<mixed>,
): CoercedVariableValues {
const errors = [];
Expand Down
4 changes: 2 additions & 2 deletions src/jsutils/dedent.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
* str === "{\n test\n}\n";
*/
export default function dedent(
strings: Array<string>,
...values: Array<string>
strings: $ReadOnlyArray<string>,
...values: $ReadOnlyArray<string>
): string {
let str = '';

Expand Down
4 changes: 3 additions & 1 deletion src/language/blockString.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ export function dedentBlockStringValue(rawString: string): string {
}

// @internal
export function getBlockStringIndentation(lines: Array<string>): number {
export function getBlockStringIndentation(
lines: $ReadOnlyArray<string>,
): number {
let commonIndent = null;

for (let i = 1; i < lines.length; i++) {
Expand Down
2 changes: 1 addition & 1 deletion src/language/printLocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function printSourceLocation(
);
}

function printPrefixedLines(lines: Array<[string, string]>): string {
function printPrefixedLines(lines: $ReadOnlyArray<[string, string]>): string {
const existingLines = lines.filter(([_, line]) => line !== undefined);

const padLen = Math.max(...existingLines.map(([prefix]) => prefix.length));
Expand Down
2 changes: 1 addition & 1 deletion src/language/visitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ function isNode(maybeNode): boolean %checks {
* If a prior visitor edits a node, no following visitors will see that node.
*/
export function visitInParallel(
visitors: Array<Visitor<ASTKindToNode>>,
visitors: $ReadOnlyArray<Visitor<ASTKindToNode>>,
): Visitor<ASTKindToNode> {
const skipping = new Array(visitors.length);

Expand Down
2 changes: 1 addition & 1 deletion src/type/definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ function fieldsToFieldsConfig(fields) {
}

export function argsToArgsConfig(
args: Array<GraphQLArgument>,
args: $ReadOnlyArray<GraphQLArgument>,
): GraphQLFieldConfigArgumentMap {
return keyValMap(
args,
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/lexicographicSortSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export function lexicographicSortSchema(schema: GraphQLSchema): GraphQLSchema {
}));
}

function sortTypes<T: GraphQLNamedType>(arr: Array<T>): Array<T> {
function sortTypes<T: GraphQLNamedType>(arr: $ReadOnlyArray<T>): Array<T> {
return sortByName(arr).map(replaceNamedType);
}

Expand Down
4 changes: 2 additions & 2 deletions src/validation/rules/FieldsOnCorrectType.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import {
export function undefinedFieldMessage(
fieldName: string,
type: string,
suggestedTypeNames: Array<string>,
suggestedFieldNames: Array<string>,
suggestedTypeNames: $ReadOnlyArray<string>,
suggestedFieldNames: $ReadOnlyArray<string>,
): string {
const quotedTypeNames = suggestedTypeNames.map(x => `"${x}"`);
const quotedFieldNames = suggestedFieldNames.map(x => `"${x}"`);
Expand Down
4 changes: 2 additions & 2 deletions src/validation/rules/KnownArgumentNames.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function unknownArgMessage(
argName: string,
fieldName: string,
typeName: string,
suggestedArgs: Array<string>,
suggestedArgs: $ReadOnlyArray<string>,
): string {
return (
`Unknown argument "${argName}" on field "${fieldName}" of type "${typeName}".` +
Expand All @@ -26,7 +26,7 @@ export function unknownArgMessage(
export function unknownDirectiveArgMessage(
argName: string,
directiveName: string,
suggestedArgs: Array<string>,
suggestedArgs: $ReadOnlyArray<string>,
): string {
return (
`Unknown argument "${argName}" on directive "@${directiveName}".` +
Expand Down
2 changes: 1 addition & 1 deletion src/validation/rules/KnownTypeNames.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { specifiedScalarTypes } from '../../type/scalars';

export function unknownTypeMessage(
typeName: string,
suggestedTypes: Array<string>,
suggestedTypes: $ReadOnlyArray<string>,
): string {
return (
`Unknown type "${typeName}".` +
Expand Down
2 changes: 1 addition & 1 deletion src/validation/rules/NoFragmentCycles.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { type ASTVisitor } from '../../language/visitor';

export function cycleErrorMessage(
fragName: string,
spreadNames: Array<string>,
spreadNames: $ReadOnlyArray<string>,
): string {
const via = spreadNames.length ? ' via ' + spreadNames.join(', ') : '';
return `Cannot spread fragment "${fragName}" within itself${via}.`;
Expand Down
2 changes: 1 addition & 1 deletion src/validation/rules/OverlappingFieldsCanBeMerged.js
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ function _collectFieldsAndFragmentNames(
// Given a series of Conflicts which occurred between two sub-fields, generate
// a single Conflict.
function subfieldConflicts(
conflicts: Array<Conflict>,
conflicts: $ReadOnlyArray<Conflict>,
responseName: string,
node1: FieldNode,
node2: FieldNode,
Expand Down
2 changes: 1 addition & 1 deletion src/validation/rules/PossibleTypeExtensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {

export function extendingUnknownTypeMessage(
typeName: string,
suggestedTypes: Array<string>,
suggestedTypes: $ReadOnlyArray<string>,
): string {
return (
`Cannot extend type "${typeName}" because it is not defined.` +
Expand Down

0 comments on commit 9b2e626

Please sign in to comment.