From 4ea800d8aa7ee0248e3c51e70ed3fbc69425b2b8 Mon Sep 17 00:00:00 2001 From: saihaj Date: Tue, 27 Oct 2020 10:17:38 -0500 Subject: [PATCH] fix: type annotation cannot appear on a constructor declaration --- src/error/GraphQLError.js | 2 +- src/language/source.js | 2 +- src/type/definition.js | 12 ++++++------ src/type/directives.js | 2 +- src/type/schema.js | 2 +- src/utilities/TypeInfo.js | 2 +- src/validation/ValidationContext.js | 6 +++--- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/error/GraphQLError.js b/src/error/GraphQLError.js index 8e214ee2d4..3040787939 100644 --- a/src/error/GraphQLError.js +++ b/src/error/GraphQLError.js @@ -83,7 +83,7 @@ export class GraphQLError extends Error { path?: ?$ReadOnlyArray, originalError?: ?(Error & { +extensions?: mixed, ... }), extensions?: ?{ [key: string]: mixed, ... }, - ): void { + ) { super(message); // Compute list of blame nodes. diff --git a/src/language/source.js b/src/language/source.js index 05a0fc9c81..a7181f4df7 100644 --- a/src/language/source.js +++ b/src/language/source.js @@ -25,7 +25,7 @@ export class Source { body: string, name: string = 'GraphQL request', locationOffset: Location = { line: 1, column: 1 }, - ): void { + ) { devAssert( typeof body === 'string', `Body must be a string. Received: ${inspect(body)}.`, diff --git a/src/type/definition.js b/src/type/definition.js index aebb4e2417..f8d25ac11c 100644 --- a/src/type/definition.js +++ b/src/type/definition.js @@ -583,7 +583,7 @@ export class GraphQLScalarType { astNode: ?ScalarTypeDefinitionNode; extensionASTNodes: ?$ReadOnlyArray; - constructor(config: $ReadOnly>): void { + constructor(config: $ReadOnly>) { const parseValue = config.parseValue ?? identityFunc; this.name = config.name; this.description = config.description; @@ -736,7 +736,7 @@ export class GraphQLObjectType { _fields: Thunk>; _interfaces: Thunk>; - constructor(config: $ReadOnly>): void { + constructor(config: $ReadOnly>) { this.name = config.name; this.description = config.description; this.isTypeOf = config.isTypeOf; @@ -1064,7 +1064,7 @@ export class GraphQLInterfaceType { _fields: Thunk>; _interfaces: Thunk>; - constructor(config: $ReadOnly>): void { + constructor(config: $ReadOnly>) { this.name = config.name; this.description = config.description; this.resolveType = config.resolveType; @@ -1183,7 +1183,7 @@ export class GraphQLUnionType { _types: Thunk>; - constructor(config: $ReadOnly>): void { + constructor(config: $ReadOnly>) { this.name = config.name; this.description = config.description; this.resolveType = config.resolveType; @@ -1301,7 +1301,7 @@ export class GraphQLEnumType /* */ { _valueLookup: Map; _nameLookup: ObjMap; - constructor(config: $ReadOnly */>): void { + constructor(config: $ReadOnly */>) { this.name = config.name; this.description = config.description; this.extensions = config.extensions && toObjMap(config.extensions); @@ -1523,7 +1523,7 @@ export class GraphQLInputObjectType { _fields: Thunk; - constructor(config: $ReadOnly): void { + constructor(config: $ReadOnly) { this.name = config.name; this.description = config.description; this.extensions = config.extensions && toObjMap(config.extensions); diff --git a/src/type/directives.js b/src/type/directives.js index 21a8055dbd..d35069f691 100644 --- a/src/type/directives.js +++ b/src/type/directives.js @@ -53,7 +53,7 @@ export class GraphQLDirective { extensions: ?ReadOnlyObjMap; astNode: ?DirectiveDefinitionNode; - constructor(config: $ReadOnly): void { + constructor(config: $ReadOnly) { this.name = config.name; this.description = config.description; this.locations = config.locations; diff --git a/src/type/schema.js b/src/type/schema.js index 230b1dcc62..4b0a6e3b12 100644 --- a/src/type/schema.js +++ b/src/type/schema.js @@ -142,7 +142,7 @@ export class GraphQLSchema { // Used as a cache for validateSchema(). __validationErrors: ?$ReadOnlyArray; - constructor(config: $ReadOnly): void { + constructor(config: $ReadOnly) { // If this schema was built from a source known to be valid, then it may be // marked with assumeValid to avoid an additional type system validation. this.__validationErrors = config.assumeValid === true ? [] : undefined; diff --git a/src/utilities/TypeInfo.js b/src/utilities/TypeInfo.js index 40c27e26df..f18b03d68e 100644 --- a/src/utilities/TypeInfo.js +++ b/src/utilities/TypeInfo.js @@ -64,7 +64,7 @@ export class TypeInfo { // Initial type may be provided in rare cases to facilitate traversals // beginning somewhere other than documents. initialType?: GraphQLType, - ): void { + ) { this._schema = schema; this._typeStack = []; this._parentTypeStack = []; diff --git a/src/validation/ValidationContext.js b/src/validation/ValidationContext.js index 9bb3dbab6b..2a0d8aef1a 100644 --- a/src/validation/ValidationContext.js +++ b/src/validation/ValidationContext.js @@ -50,7 +50,7 @@ export class ASTValidationContext { $ReadOnlyArray, >; - constructor(ast: DocumentNode, onError: (err: GraphQLError) => void): void { + constructor(ast: DocumentNode, onError: (err: GraphQLError) => void) { this._ast = ast; this._fragments = undefined; this._fragmentSpreads = new Map(); @@ -141,7 +141,7 @@ export class SDLValidationContext extends ASTValidationContext { ast: DocumentNode, schema: ?GraphQLSchema, onError: (err: GraphQLError) => void, - ): void { + ) { super(ast, onError); this._schema = schema; } @@ -167,7 +167,7 @@ export class ValidationContext extends ASTValidationContext { ast: DocumentNode, typeInfo: TypeInfo, onError: (err: GraphQLError) => void, - ): void { + ) { super(ast, onError); this._schema = schema; this._typeInfo = typeInfo;