Skip to content

Commit

Permalink
fix: type annotation cannot appear on a constructor declaration (#2878)
Browse files Browse the repository at this point in the history
  • Loading branch information
saihaj committed Jan 11, 2021
1 parent 998bea6 commit 661ff1a
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/error/GraphQLError.js
Expand Up @@ -83,7 +83,7 @@ export class GraphQLError extends Error {
path?: ?$ReadOnlyArray<string | number>,
originalError?: ?(Error & { +extensions?: mixed, ... }),
extensions?: ?{ [key: string]: mixed, ... },
): void {
) {
super(message);

// Compute list of blame nodes.
Expand Down
2 changes: 1 addition & 1 deletion src/language/source.js
Expand Up @@ -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)}.`,
Expand Down
12 changes: 6 additions & 6 deletions src/type/definition.js
Expand Up @@ -583,7 +583,7 @@ export class GraphQLScalarType {
astNode: ?ScalarTypeDefinitionNode;
extensionASTNodes: ?$ReadOnlyArray<ScalarTypeExtensionNode>;

constructor(config: $ReadOnly<GraphQLScalarTypeConfig<mixed, mixed>>): void {
constructor(config: $ReadOnly<GraphQLScalarTypeConfig<mixed, mixed>>) {
const parseValue = config.parseValue ?? identityFunc;
this.name = config.name;
this.description = config.description;
Expand Down Expand Up @@ -736,7 +736,7 @@ export class GraphQLObjectType {
_fields: Thunk<GraphQLFieldMap<any, any>>;
_interfaces: Thunk<Array<GraphQLInterfaceType>>;

constructor(config: $ReadOnly<GraphQLObjectTypeConfig<any, any>>): void {
constructor(config: $ReadOnly<GraphQLObjectTypeConfig<any, any>>) {
this.name = config.name;
this.description = config.description;
this.isTypeOf = config.isTypeOf;
Expand Down Expand Up @@ -1064,7 +1064,7 @@ export class GraphQLInterfaceType {
_fields: Thunk<GraphQLFieldMap<any, any>>;
_interfaces: Thunk<Array<GraphQLInterfaceType>>;

constructor(config: $ReadOnly<GraphQLInterfaceTypeConfig<any, any>>): void {
constructor(config: $ReadOnly<GraphQLInterfaceTypeConfig<any, any>>) {
this.name = config.name;
this.description = config.description;
this.resolveType = config.resolveType;
Expand Down Expand Up @@ -1183,7 +1183,7 @@ export class GraphQLUnionType {

_types: Thunk<Array<GraphQLObjectType>>;

constructor(config: $ReadOnly<GraphQLUnionTypeConfig<any, any>>): void {
constructor(config: $ReadOnly<GraphQLUnionTypeConfig<any, any>>) {
this.name = config.name;
this.description = config.description;
this.resolveType = config.resolveType;
Expand Down Expand Up @@ -1301,7 +1301,7 @@ export class GraphQLEnumType /* <T> */ {
_valueLookup: Map<any /* T */, GraphQLEnumValue>;
_nameLookup: ObjMap<GraphQLEnumValue>;

constructor(config: $ReadOnly<GraphQLEnumTypeConfig /* <T> */>): void {
constructor(config: $ReadOnly<GraphQLEnumTypeConfig /* <T> */>) {
this.name = config.name;
this.description = config.description;
this.extensions = config.extensions && toObjMap(config.extensions);
Expand Down Expand Up @@ -1523,7 +1523,7 @@ export class GraphQLInputObjectType {
_fields: Thunk<GraphQLInputFieldMap>;
constructor(config: $ReadOnly<GraphQLInputObjectTypeConfig>): void {
constructor(config: $ReadOnly<GraphQLInputObjectTypeConfig>) {
this.name = config.name;
this.description = config.description;
this.extensions = config.extensions && toObjMap(config.extensions);
Expand Down
2 changes: 1 addition & 1 deletion src/type/directives.js
Expand Up @@ -53,7 +53,7 @@ export class GraphQLDirective {
extensions: ?ReadOnlyObjMap<mixed>;
astNode: ?DirectiveDefinitionNode;

constructor(config: $ReadOnly<GraphQLDirectiveConfig>): void {
constructor(config: $ReadOnly<GraphQLDirectiveConfig>) {
this.name = config.name;
this.description = config.description;
this.locations = config.locations;
Expand Down
2 changes: 1 addition & 1 deletion src/type/schema.js
Expand Up @@ -142,7 +142,7 @@ export class GraphQLSchema {
// Used as a cache for validateSchema().
__validationErrors: ?$ReadOnlyArray<GraphQLError>;

constructor(config: $ReadOnly<GraphQLSchemaConfig>): void {
constructor(config: $ReadOnly<GraphQLSchemaConfig>) {
// 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;
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/TypeInfo.js
Expand Up @@ -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 = [];
Expand Down
6 changes: 3 additions & 3 deletions src/validation/ValidationContext.js
Expand Up @@ -50,7 +50,7 @@ export class ASTValidationContext {
$ReadOnlyArray<FragmentDefinitionNode>,
>;

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();
Expand Down Expand Up @@ -141,7 +141,7 @@ export class SDLValidationContext extends ASTValidationContext {
ast: DocumentNode,
schema: ?GraphQLSchema,
onError: (err: GraphQLError) => void,
): void {
) {
super(ast, onError);
this._schema = schema;
}
Expand All @@ -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;
Expand Down

0 comments on commit 661ff1a

Please sign in to comment.