Skip to content

Commit

Permalink
Flow: add missing names to arguments of function types (#3072)
Browse files Browse the repository at this point in the history
In preparation to TS convertion
  • Loading branch information
IvanGoncharov committed May 10, 2021
1 parent d695f53 commit bd5583c
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/execution/values.js
Expand Up @@ -74,7 +74,7 @@ function coerceVariableValues(
schema: GraphQLSchema,
varDefNodes: $ReadOnlyArray<VariableDefinitionNode>,
inputs: { +[variable: string]: mixed, ... },
onError: (GraphQLError) => void,
onError: (error: GraphQLError) => void,
): { [variable: string]: mixed, ... } {
const coercedValues = {};
for (const varDefNode of varDefNodes) {
Expand Down
2 changes: 1 addition & 1 deletion src/jsutils/instanceOf.js
Expand Up @@ -4,7 +4,7 @@
* See: https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production
* See: https://webpack.js.org/guides/production/
*/
export const instanceOf: (mixed, Constructor) => boolean =
export const instanceOf: (value: mixed, constructor: Constructor) => boolean =
process.env.NODE_ENV === 'production'
? // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
function instanceOf(value: mixed, constructor: Constructor): boolean {
Expand Down
2 changes: 1 addition & 1 deletion src/jsutils/memoize3.js
Expand Up @@ -6,7 +6,7 @@ export function memoize3<
A2: { ... } | $ReadOnlyArray<mixed>,
A3: { ... } | $ReadOnlyArray<mixed>,
R,
>(fn: (A1, A2, A3) => R): (A1, A2, A3) => R {
>(fn: (a1: A1, a2: A2, a3: A3) => R): (a1: A1, a2: A2, a3: A3) => R {
let cache0;

return function memoized(a1, a2, a3) {
Expand Down
2 changes: 1 addition & 1 deletion src/jsutils/promiseReduce.js
Expand Up @@ -11,7 +11,7 @@ import { isPromise } from './isPromise';
*/
export function promiseReduce<T, U>(
values: $ReadOnlyArray<T>,
callback: (U, T) => PromiseOrValue<U>,
callback: (accumulator: U, currentValue: T) => PromiseOrValue<U>,
initialValue: PromiseOrValue<U>,
): PromiseOrValue<U> {
return values.reduce(
Expand Down
2 changes: 1 addition & 1 deletion src/language/__tests__/predicates-test.js
Expand Up @@ -21,7 +21,7 @@ const allASTNodes: Array<ASTNode> = Object.values(Kind).map(
(kind) => ({ kind }: any),
);

function filterNodes(predicate: (ASTNode) => boolean): Array<string> {
function filterNodes(predicate: (node: ASTNode) => boolean): Array<string> {
return allASTNodes.filter(predicate).map(({ kind }) => kind);
}

Expand Down
2 changes: 1 addition & 1 deletion src/language/visitor.js
Expand Up @@ -11,7 +11,7 @@ export type ASTVisitor = $Shape<EnterLeaveVisitor<ASTNode> & KindVisitor>;

type KindVisitor = $ObjMap<
ASTKindToNode,
<Node>(Node) => ASTVisitFn<Node> | EnterLeaveVisitor<Node>,
<Node>(node: Node) => ASTVisitFn<Node> | EnterLeaveVisitor<Node>,
>;

type EnterLeaveVisitor<TVisitedNode: ASTNode> = {|
Expand Down
2 changes: 1 addition & 1 deletion src/subscription/__tests__/mapAsyncIterator-test.js
Expand Up @@ -276,7 +276,7 @@ describe('mapAsyncIterator', () => {
.with.property('message', 'Goodbye');
});

async function testClosesSourceWithMapper<T>(mapper: (number) => T) {
async function testClosesSourceWithMapper<T>(mapper: (value: number) => T) {
let didVisitFinally = false;

async function* source() {
Expand Down
4 changes: 2 additions & 2 deletions src/subscription/__tests__/simplePubSub.js
Expand Up @@ -3,7 +3,7 @@
* PubSub system for tests.
*/
export class SimplePubSub<T> {
_subscribers: Set<(T) => void>;
_subscribers: Set<(value: T) => void>;

constructor() {
this._subscribers = new Set();
Expand All @@ -16,7 +16,7 @@ export class SimplePubSub<T> {
return this._subscribers.size > 0;
}

getSubscriber<R>(transform: (T) => R): AsyncGenerator<R, void, void> {
getSubscriber<R>(transform: (value: T) => R): AsyncGenerator<R, void, void> {
const pullQueue: Array<(result: IteratorResult<R, void>) => void> = [];
const pushQueue = [];
let listening = true;
Expand Down
2 changes: 1 addition & 1 deletion src/subscription/mapAsyncIterator.js
Expand Up @@ -6,7 +6,7 @@ import type { PromiseOrValue } from '../jsutils/PromiseOrValue';
*/
export function mapAsyncIterator<T, U, R = void>(
iterable: AsyncGenerator<T, R, void> | AsyncIterable<T>,
callback: (T) => PromiseOrValue<U>,
callback: (value: T) => PromiseOrValue<U>,
): AsyncGenerator<U, R, void> {
// $FlowIssue[incompatible-use]
const iterator = iterable[Symbol.asyncIterator]();
Expand Down
2 changes: 1 addition & 1 deletion src/type/validate.js
Expand Up @@ -557,7 +557,7 @@ function validateInputFields(

function createInputObjectCircularRefsValidator(
context: SchemaValidationContext,
): (GraphQLInputObjectType) => void {
): (inputObj: GraphQLInputObjectType) => void {
// Modified copy of algorithm from 'src/validation/rules/NoFragmentCycles.js'.
// Tracks already visited types to maintain O(N) and to ensure that cycles
// are not redundantly reported.
Expand Down
7 changes: 5 additions & 2 deletions src/utilities/lexicographicSortSchema.js
Expand Up @@ -156,7 +156,10 @@ export function lexicographicSortSchema(schema: GraphQLSchema): GraphQLSchema {
}
}

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

function sortBy<T>(
array: $ReadOnlyArray<T>,
mapToKey: (T) => string,
mapToKey: (item: T) => string,
): Array<T> {
return array.slice().sort((obj1, obj2) => {
const key1 = mapToKey(obj1);
Expand Down
6 changes: 3 additions & 3 deletions src/validation/ValidationContext.js
Expand Up @@ -128,7 +128,7 @@ export class ASTValidationContext {
}
}

export type ASTValidationRule = (ASTValidationContext) => ASTVisitor;
export type ASTValidationRule = (context: ASTValidationContext) => ASTVisitor;

export class SDLValidationContext extends ASTValidationContext {
_schema: ?GraphQLSchema;
Expand All @@ -147,7 +147,7 @@ export class SDLValidationContext extends ASTValidationContext {
}
}

export type SDLValidationRule = (SDLValidationContext) => ASTVisitor;
export type SDLValidationRule = (context: SDLValidationContext) => ASTVisitor;

export class ValidationContext extends ASTValidationContext {
_schema: GraphQLSchema;
Expand Down Expand Up @@ -246,4 +246,4 @@ export class ValidationContext extends ASTValidationContext {
}
}

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

0 comments on commit bd5583c

Please sign in to comment.