Skip to content

Commit bd5583c

Browse files
Flow: add missing names to arguments of function types (#3072)
In preparation to TS convertion
1 parent d695f53 commit bd5583c

File tree

12 files changed

+19
-16
lines changed

12 files changed

+19
-16
lines changed

src/execution/values.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ function coerceVariableValues(
7474
schema: GraphQLSchema,
7575
varDefNodes: $ReadOnlyArray<VariableDefinitionNode>,
7676
inputs: { +[variable: string]: mixed, ... },
77-
onError: (GraphQLError) => void,
77+
onError: (error: GraphQLError) => void,
7878
): { [variable: string]: mixed, ... } {
7979
const coercedValues = {};
8080
for (const varDefNode of varDefNodes) {

src/jsutils/instanceOf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* See: https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production
55
* See: https://webpack.js.org/guides/production/
66
*/
7-
export const instanceOf: (mixed, Constructor) => boolean =
7+
export const instanceOf: (value: mixed, constructor: Constructor) => boolean =
88
process.env.NODE_ENV === 'production'
99
? // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
1010
function instanceOf(value: mixed, constructor: Constructor): boolean {

src/jsutils/memoize3.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export function memoize3<
66
A2: { ... } | $ReadOnlyArray<mixed>,
77
A3: { ... } | $ReadOnlyArray<mixed>,
88
R,
9-
>(fn: (A1, A2, A3) => R): (A1, A2, A3) => R {
9+
>(fn: (a1: A1, a2: A2, a3: A3) => R): (a1: A1, a2: A2, a3: A3) => R {
1010
let cache0;
1111

1212
return function memoized(a1, a2, a3) {

src/jsutils/promiseReduce.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { isPromise } from './isPromise';
1111
*/
1212
export function promiseReduce<T, U>(
1313
values: $ReadOnlyArray<T>,
14-
callback: (U, T) => PromiseOrValue<U>,
14+
callback: (accumulator: U, currentValue: T) => PromiseOrValue<U>,
1515
initialValue: PromiseOrValue<U>,
1616
): PromiseOrValue<U> {
1717
return values.reduce(

src/language/__tests__/predicates-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const allASTNodes: Array<ASTNode> = Object.values(Kind).map(
2121
(kind) => ({ kind }: any),
2222
);
2323

24-
function filterNodes(predicate: (ASTNode) => boolean): Array<string> {
24+
function filterNodes(predicate: (node: ASTNode) => boolean): Array<string> {
2525
return allASTNodes.filter(predicate).map(({ kind }) => kind);
2626
}
2727

src/language/visitor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export type ASTVisitor = $Shape<EnterLeaveVisitor<ASTNode> & KindVisitor>;
1111

1212
type KindVisitor = $ObjMap<
1313
ASTKindToNode,
14-
<Node>(Node) => ASTVisitFn<Node> | EnterLeaveVisitor<Node>,
14+
<Node>(node: Node) => ASTVisitFn<Node> | EnterLeaveVisitor<Node>,
1515
>;
1616

1717
type EnterLeaveVisitor<TVisitedNode: ASTNode> = {|

src/subscription/__tests__/mapAsyncIterator-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ describe('mapAsyncIterator', () => {
276276
.with.property('message', 'Goodbye');
277277
});
278278

279-
async function testClosesSourceWithMapper<T>(mapper: (number) => T) {
279+
async function testClosesSourceWithMapper<T>(mapper: (value: number) => T) {
280280
let didVisitFinally = false;
281281

282282
async function* source() {

src/subscription/__tests__/simplePubSub.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* PubSub system for tests.
44
*/
55
export class SimplePubSub<T> {
6-
_subscribers: Set<(T) => void>;
6+
_subscribers: Set<(value: T) => void>;
77

88
constructor() {
99
this._subscribers = new Set();
@@ -16,7 +16,7 @@ export class SimplePubSub<T> {
1616
return this._subscribers.size > 0;
1717
}
1818

19-
getSubscriber<R>(transform: (T) => R): AsyncGenerator<R, void, void> {
19+
getSubscriber<R>(transform: (value: T) => R): AsyncGenerator<R, void, void> {
2020
const pullQueue: Array<(result: IteratorResult<R, void>) => void> = [];
2121
const pushQueue = [];
2222
let listening = true;

src/subscription/mapAsyncIterator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { PromiseOrValue } from '../jsutils/PromiseOrValue';
66
*/
77
export function mapAsyncIterator<T, U, R = void>(
88
iterable: AsyncGenerator<T, R, void> | AsyncIterable<T>,
9-
callback: (T) => PromiseOrValue<U>,
9+
callback: (value: T) => PromiseOrValue<U>,
1010
): AsyncGenerator<U, R, void> {
1111
// $FlowIssue[incompatible-use]
1212
const iterator = iterable[Symbol.asyncIterator]();

src/type/validate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ function validateInputFields(
557557

558558
function createInputObjectCircularRefsValidator(
559559
context: SchemaValidationContext,
560-
): (GraphQLInputObjectType) => void {
560+
): (inputObj: GraphQLInputObjectType) => void {
561561
// Modified copy of algorithm from 'src/validation/rules/NoFragmentCycles.js'.
562562
// Tracks already visited types to maintain O(N) and to ensure that cycles
563563
// are not redundantly reported.

src/utilities/lexicographicSortSchema.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,10 @@ export function lexicographicSortSchema(schema: GraphQLSchema): GraphQLSchema {
156156
}
157157
}
158158

159-
function sortObjMap<T, R>(map: ObjMap<T>, sortValueFn: (T) => R): ObjMap<R> {
159+
function sortObjMap<T, R>(
160+
map: ObjMap<T>,
161+
sortValueFn: (value: T) => R,
162+
): ObjMap<R> {
160163
const sortedMap = Object.create(null);
161164
const sortedEntries = sortBy(Object.entries(map), ([key]) => key);
162165
for (const [key, value] of sortedEntries) {
@@ -173,7 +176,7 @@ function sortByName<T: { +name: string, ... }>(
173176

174177
function sortBy<T>(
175178
array: $ReadOnlyArray<T>,
176-
mapToKey: (T) => string,
179+
mapToKey: (item: T) => string,
177180
): Array<T> {
178181
return array.slice().sort((obj1, obj2) => {
179182
const key1 = mapToKey(obj1);

src/validation/ValidationContext.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export class ASTValidationContext {
128128
}
129129
}
130130

131-
export type ASTValidationRule = (ASTValidationContext) => ASTVisitor;
131+
export type ASTValidationRule = (context: ASTValidationContext) => ASTVisitor;
132132

133133
export class SDLValidationContext extends ASTValidationContext {
134134
_schema: ?GraphQLSchema;
@@ -147,7 +147,7 @@ export class SDLValidationContext extends ASTValidationContext {
147147
}
148148
}
149149

150-
export type SDLValidationRule = (SDLValidationContext) => ASTVisitor;
150+
export type SDLValidationRule = (context: SDLValidationContext) => ASTVisitor;
151151

152152
export class ValidationContext extends ASTValidationContext {
153153
_schema: GraphQLSchema;
@@ -246,4 +246,4 @@ export class ValidationContext extends ASTValidationContext {
246246
}
247247
}
248248

249-
export type ValidationRule = (ValidationContext) => ASTVisitor;
249+
export type ValidationRule = (context: ValidationContext) => ASTVisitor;

0 commit comments

Comments
 (0)