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

Flow: Remove some of the 'existential type' usages #2015

Merged
merged 1 commit into from Jul 4, 2019
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
28 changes: 13 additions & 15 deletions src/execution/execute.js
Expand Up @@ -293,8 +293,8 @@ export function buildExecutionContext(
contextValue: mixed,
rawVariableValues: ?{ +[variable: string]: mixed, ... },
operationName: ?string,
fieldResolver: ?GraphQLFieldResolver<any, any>,
typeResolver?: ?GraphQLTypeResolver<any, any>,
fieldResolver: ?GraphQLFieldResolver<mixed, mixed>,
typeResolver?: ?GraphQLTypeResolver<mixed, mixed>,
): $ReadOnlyArray<GraphQLError> | ExecutionContext {
const errors: Array<GraphQLError> = [];
let operation: OperationDefinitionNode | void;
Expand Down Expand Up @@ -682,7 +682,7 @@ function resolveField(

export function buildResolveInfo(
exeContext: ExecutionContext,
fieldDef: GraphQLField<*, *>,
fieldDef: GraphQLField<mixed, mixed>,
fieldNodes: $ReadOnlyArray<FieldNode>,
parentType: GraphQLObjectType,
path: ResponsePath,
Expand All @@ -705,12 +705,12 @@ export function buildResolveInfo(

// Isolates the "ReturnOrAbrupt" behavior to not de-opt the `resolveField`
// function. Returns the result of resolveFn or the abrupt-return Error object.
export function resolveFieldValueOrError<TSource>(
export function resolveFieldValueOrError(
exeContext: ExecutionContext,
fieldDef: GraphQLField<TSource, *>,
fieldDef: GraphQLField<mixed, mixed>,
fieldNodes: $ReadOnlyArray<FieldNode>,
resolveFn: GraphQLFieldResolver<TSource, *>,
source: TSource,
resolveFn: GraphQLFieldResolver<mixed, mixed>,
source: mixed,
info: GraphQLResolveInfo,
): Error | mixed {
try {
Expand Down Expand Up @@ -1165,7 +1165,7 @@ function _collectSubfields(
* Otherwise, test each possible type for the abstract type by calling
* isTypeOf for the object being coerced, returning the first type that matches.
*/
export const defaultTypeResolver: GraphQLTypeResolver<any, *> = function(
export const defaultTypeResolver: GraphQLTypeResolver<mixed, mixed> = function(
value,
contextValue,
info,
Expand Down Expand Up @@ -1211,12 +1211,10 @@ export const defaultTypeResolver: GraphQLTypeResolver<any, *> = function(
* and returns it as the result, or if it's a function, returns the result
* of calling that function while passing along args and context value.
*/
export const defaultFieldResolver: GraphQLFieldResolver<any, *> = function(
source,
args,
contextValue,
info,
) {
export const defaultFieldResolver: GraphQLFieldResolver<
mixed,
mixed,
> = function(source: any, args, contextValue, info) {
// ensure source is a value for which property access is acceptable.
if (isObjectLike(source) || typeof source === 'function') {
const property = source[info.fieldName];
Expand All @@ -1240,7 +1238,7 @@ export function getFieldDef(
schema: GraphQLSchema,
parentType: GraphQLObjectType,
fieldName: string,
): ?GraphQLField<*, *> {
): ?GraphQLField<mixed, mixed> {
if (
fieldName === SchemaMetaFieldDef.name &&
schema.getQueryType() === parentType
Expand Down
2 changes: 1 addition & 1 deletion src/execution/values.js
Expand Up @@ -119,7 +119,7 @@ export function getVariableValues(
* Object prototype.
*/
export function getArgumentValues(
def: GraphQLField<*, *> | GraphQLDirective,
def: GraphQLField<mixed, mixed> | GraphQLDirective,
node: FieldNode | DirectiveNode,
variableValues?: ?ObjMap<mixed>,
): { [argument: string]: mixed, ... } {
Expand Down
2 changes: 1 addition & 1 deletion src/jsutils/defineToStringTag.js
Expand Up @@ -13,7 +13,7 @@
* typically one of your own creation through the class keyword; `class A {}`,
* for example.
*/
export default function defineToStringTag(classObject: Class<any>): void {
export default function defineToStringTag(classObject: Class<mixed>): void {
if (typeof Symbol === 'function' && Symbol.toStringTag) {
Object.defineProperty(classObject.prototype, Symbol.toStringTag, {
get() {
Expand Down
4 changes: 2 additions & 2 deletions src/language/lexer.js
Expand Up @@ -172,7 +172,7 @@ function printCharCode(code) {
* punctuators immediately or calls the appropriate helper function for more
* complicated tokens.
*/
function readToken(lexer: Lexer<*>, prev: Token): Token {
function readToken(lexer: Lexer<mixed>, prev: Token): Token {
const source = lexer.source;
const body = source.body;
const bodyLength = body.length;
Expand Down Expand Up @@ -339,7 +339,7 @@ function unexpectedCharacterMessage(code) {
function positionAfterWhitespace(
body: string,
startPosition: number,
lexer: Lexer<*>,
lexer: Lexer<mixed>,
): number {
const bodyLength = body.length;
let position = startPosition;
Expand Down
4 changes: 2 additions & 2 deletions src/type/definition.js
Expand Up @@ -727,7 +727,7 @@ defineToStringTag(GraphQLObjectType);
defineToJSON(GraphQLObjectType);

function defineInterfaces(
config: GraphQLObjectTypeConfig<*, *>,
config: GraphQLObjectTypeConfig<mixed, mixed>,
): Array<GraphQLInterfaceType> {
const interfaces = resolveThunk(config.interfaces) || [];
invariant(
Expand Down Expand Up @@ -1096,7 +1096,7 @@ defineToStringTag(GraphQLUnionType);
defineToJSON(GraphQLUnionType);

function defineTypes(
config: GraphQLUnionTypeConfig<*, *>,
config: GraphQLUnionTypeConfig<mixed, mixed>,
): Array<GraphQLObjectType> {
const types = resolveThunk(config.types) || [];
invariant(
Expand Down
6 changes: 3 additions & 3 deletions src/utilities/TypeInfo.js
Expand Up @@ -42,7 +42,7 @@ export class TypeInfo {
_typeStack: Array<?GraphQLOutputType>;
_parentTypeStack: Array<?GraphQLCompositeType>;
_inputTypeStack: Array<?GraphQLInputType>;
_fieldDefStack: Array<?GraphQLField<*, *>>;
_fieldDefStack: Array<?GraphQLField<mixed, mixed>>;
_defaultValueStack: Array<?mixed>;
_directive: ?GraphQLDirective;
_argument: ?GraphQLArgument;
Expand Down Expand Up @@ -106,7 +106,7 @@ export class TypeInfo {
}
}

getFieldDef(): ?GraphQLField<*, *> {
getFieldDef(): ?GraphQLField<mixed, mixed> {
if (this._fieldDefStack.length > 0) {
return this._fieldDefStack[this._fieldDefStack.length - 1];
}
Expand Down Expand Up @@ -293,7 +293,7 @@ function getFieldDef(
schema: GraphQLSchema,
parentType: GraphQLType,
fieldNode: FieldNode,
): ?GraphQLField<*, *> {
): ?GraphQLField<mixed, mixed> {
const name = fieldNode.name.value;
if (
name === SchemaMetaFieldDef.name &&
Expand Down
4 changes: 2 additions & 2 deletions src/utilities/findBreakingChanges.js
Expand Up @@ -359,8 +359,8 @@ function findFieldChanges(

function findArgChanges(
oldType: GraphQLObjectType | GraphQLInterfaceType,
oldField: GraphQLField<*, *>,
newField: GraphQLField<*, *>,
oldField: GraphQLField<mixed, mixed>,
newField: GraphQLField<mixed, mixed>,
): Array<BreakingChange | DangerousChange> {
const schemaChanges = [];
const argsDiff = diff(oldField.args, newField.args);
Expand Down
2 changes: 1 addition & 1 deletion src/validation/ValidationContext.js
Expand Up @@ -227,7 +227,7 @@ export class ValidationContext extends ASTValidationContext {
return this._typeInfo.getParentInputType();
}

getFieldDef(): ?GraphQLField<*, *> {
getFieldDef(): ?GraphQLField<mixed, mixed> {
return this._typeInfo.getFieldDef();
}

Expand Down
6 changes: 5 additions & 1 deletion src/validation/rules/OverlappingFieldsCanBeMerged.js
Expand Up @@ -100,7 +100,11 @@ type ConflictReason = [string, ConflictReasonMessage];
// Reason is a string, or a nested list of conflicts.
type ConflictReasonMessage = string | Array<ConflictReason>;
// Tuple defining a field node in a context.
type NodeAndDef = [GraphQLCompositeType, FieldNode, ?GraphQLField<*, *>];
type NodeAndDef = [
GraphQLCompositeType,
FieldNode,
?GraphQLField<mixed, mixed>,
];
// Map of array of those.
type NodeAndDefCollection = ObjMap<Array<NodeAndDef>>;

Expand Down