From 4116d5e1a5bc2f40bfaf54dd2efe55bb5359b5de 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.ts | 2 +- src/language/source.ts | 2 +- src/type/definition.ts | 12 ++++++------ src/type/directives.ts | 2 +- src/type/schema.ts | 2 +- src/utilities/TypeInfo.ts | 2 +- src/validation/ValidationContext.ts | 6 +++--- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/error/GraphQLError.ts b/src/error/GraphQLError.ts index 1a879fc902d..456799d93b1 100644 --- a/src/error/GraphQLError.ts +++ b/src/error/GraphQLError.ts @@ -83,7 +83,7 @@ export class GraphQLError extends Error { path?: Maybe>, originalError?: Maybe<(Error & { readonly extensions?: unknown })>, extensions?: Maybe<{ [key: string]: unknown }>, - ): void { + ) { super(message); // Compute list of blame nodes. diff --git a/src/language/source.ts b/src/language/source.ts index 4b4faf1e36d..e737bf7ec8c 100644 --- a/src/language/source.ts +++ b/src/language/source.ts @@ -23,7 +23,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.ts b/src/type/definition.ts index 7d04f3817d9..5a38dc6396c 100644 --- a/src/type/definition.ts +++ b/src/type/definition.ts @@ -552,7 +552,7 @@ export class GraphQLScalarType { astNode: Maybe; extensionASTNodes: Maybe>; - constructor(config: $ReadOnly>): void { + constructor(config: $ReadOnly>) { const parseValue = config.parseValue ?? identityFunc; this.name = config.name; this.description = config.description; @@ -699,7 +699,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; @@ -1013,7 +1013,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; @@ -1126,7 +1126,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; @@ -1238,7 +1238,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); @@ -1446,7 +1446,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.ts b/src/type/directives.ts index d9adac9f1bd..9bc3659f000 100644 --- a/src/type/directives.ts +++ b/src/type/directives.ts @@ -52,7 +52,7 @@ export class GraphQLDirective { extensions: Maybe>; astNode: Maybe; - 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.ts b/src/type/schema.ts index 1ac1a10beff..299db414612 100644 --- a/src/type/schema.ts +++ b/src/type/schema.ts @@ -139,7 +139,7 @@ export class GraphQLSchema { // Used as a cache for validateSchema(). __validationErrors: Maybe>; - 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.ts b/src/utilities/TypeInfo.ts index 115c994929f..94e5d4a073b 100644 --- a/src/utilities/TypeInfo.ts +++ b/src/utilities/TypeInfo.ts @@ -63,7 +63,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.ts b/src/validation/ValidationContext.ts index 7408412285e..b7f676b1467 100644 --- a/src/validation/ValidationContext.ts +++ b/src/validation/ValidationContext.ts @@ -51,7 +51,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(); @@ -142,7 +142,7 @@ export class SDLValidationContext extends ASTValidationContext { ast: DocumentNode, schema: Maybe, onError: (err: GraphQLError) => void, - ): void { + ) { super(ast, onError); this._schema = schema; } @@ -168,7 +168,7 @@ export class ValidationContext extends ASTValidationContext { ast: DocumentNode, typeInfo: TypeInfo, onError: (err: GraphQLError) => void, - ): void { + ) { super(ast, onError); this._schema = schema; this._typeInfo = typeInfo;