From c3292db017a6f20c8249f525b452d20e76ab6fae Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Sun, 5 Aug 2018 21:18:54 +0300 Subject: [PATCH] Remove some unneeded 'any' (#1448) --- src/error/GraphQLError.js | 5 ++--- src/jsutils/instanceOf.js | 2 +- src/type/definition.js | 10 +++++----- src/utilities/TypeInfo.js | 3 +-- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/error/GraphQLError.js b/src/error/GraphQLError.js index ecd7997c3e..89e540e375 100644 --- a/src/error/GraphQLError.js +++ b/src/error/GraphQLError.js @@ -95,7 +95,7 @@ export function GraphQLError( // eslint-disable-line no-redeclare source?: ?Source, positions?: ?$ReadOnlyArray, path?: ?$ReadOnlyArray, - originalError?: ?Error, + originalError?: ?Error & { +extensions: mixed }, extensions?: ?{ [key: string]: mixed }, ) { // Compute list of blame nodes. @@ -139,8 +139,7 @@ export function GraphQLError( // eslint-disable-line no-redeclare }, []); } - const _extensions = - extensions || (originalError && (originalError: any).extensions); + const _extensions = extensions || (originalError && originalError.extensions); Object.defineProperties(this, { message: { diff --git a/src/jsutils/instanceOf.js b/src/jsutils/instanceOf.js index db485c30b1..1cb4d2af17 100644 --- a/src/jsutils/instanceOf.js +++ b/src/jsutils/instanceOf.js @@ -20,7 +20,7 @@ declare function instanceOf( // See: https://webpack.js.org/guides/production/ export default (process.env.NODE_ENV === 'production' ? // eslint-disable-next-line no-shadow - function instanceOf(value: any, constructor: any) { + function instanceOf(value: mixed, constructor: mixed) { return value instanceof constructor; } : // eslint-disable-next-line no-shadow diff --git a/src/type/definition.js b/src/type/definition.js index 8507c387d6..bf5e5449fb 100644 --- a/src/type/definition.js +++ b/src/type/definition.js @@ -70,7 +70,7 @@ export function isType(type: mixed): boolean %checks { export function assertType(type: mixed): GraphQLType { invariant(isType(type), `Expected ${inspect(type)} to be a GraphQL type.`); - return (type: any); + return type; } /** @@ -343,7 +343,7 @@ declare class GraphQLList<+T: GraphQLType> { +ofType: T; static (ofType: T): GraphQLList; // Note: constructors cannot be used for covariant types. Drop the "new". - constructor(ofType: any): void; + constructor(ofType: GraphQLType): void; } // eslint-disable-next-line no-redeclare export function GraphQLList(ofType) { @@ -384,7 +384,7 @@ declare class GraphQLNonNull<+T: GraphQLNullableType> { +ofType: T; static (ofType: T): GraphQLNonNull; // Note: constructors cannot be used for covariant types. Drop the "new". - constructor(ofType: any): void; + constructor(ofType: GraphQLType): void; } // eslint-disable-next-line no-redeclare export function GraphQLNonNull(ofType) { @@ -1076,7 +1076,7 @@ export class GraphQLEnumType /* */ { return this._nameLookup[name]; } - serialize(value: any /* T */): ?string { + serialize(value: mixed /* T */): ?string { const enumValue = this._valueLookup.get(value); if (enumValue) { return enumValue.name; @@ -1226,7 +1226,7 @@ defineToJSON(GraphQLInputObjectType); function defineInputFieldMap( config: GraphQLInputObjectTypeConfig, ): GraphQLInputFieldMap { - const fieldMap: any = resolveThunk(config.fields) || {}; + const fieldMap = resolveThunk(config.fields) || {}; invariant( isPlainObj(fieldMap), `${config.name} fields must be an object with field names as keys or a ` + diff --git a/src/utilities/TypeInfo.js b/src/utilities/TypeInfo.js index 67911758c2..b217131acd 100644 --- a/src/utilities/TypeInfo.js +++ b/src/utilities/TypeInfo.js @@ -139,8 +139,7 @@ export class TypeInfo { return this._enumValue; } - // Flow does not yet handle this case. - enter(node: any /* ASTNode */) { + enter(node: ASTNode) { const schema = this._schema; // Note: many of the types below are explicitly typed as "mixed" to drop // any assumptions of a valid schema to ensure runtime types are properly