Skip to content

Add void returns to constructors #863

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

Merged
merged 1 commit into from
May 18, 2017
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/language/source.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class Source {
body: string;
name: string;

constructor(body: string, name?: string) {
constructor(body: string, name?: string): void {
this.body = body;
this.name = name || 'GraphQL';
}
Expand Down
16 changes: 8 additions & 8 deletions src/type/definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ export class GraphQLScalarType {

_scalarConfig: GraphQLScalarTypeConfig<*, *>;

constructor(config: GraphQLScalarTypeConfig<*, *>) {
constructor(config: GraphQLScalarTypeConfig<*, *>): void {
assertValidName(config.name);
this.name = config.name;
this.description = config.description;
Expand Down Expand Up @@ -417,7 +417,7 @@ export class GraphQLObjectType {
_fields: GraphQLFieldMap<*, *>;
_interfaces: Array<GraphQLInterfaceType>;

constructor(config: GraphQLObjectTypeConfig<*, *>) {
constructor(config: GraphQLObjectTypeConfig<*, *>): void {
assertValidName(config.name, config.isIntrospection);
this.name = config.name;
this.description = config.description;
Expand Down Expand Up @@ -696,7 +696,7 @@ export class GraphQLInterfaceType {
_typeConfig: GraphQLInterfaceTypeConfig<*, *>;
_fields: GraphQLFieldMap<*, *>;

constructor(config: GraphQLInterfaceTypeConfig<*, *>) {
constructor(config: GraphQLInterfaceTypeConfig<*, *>): void {
assertValidName(config.name);
this.name = config.name;
this.description = config.description;
Expand Down Expand Up @@ -774,7 +774,7 @@ export class GraphQLUnionType {
_types: Array<GraphQLObjectType>;
_possibleTypeNames: {[typeName: string]: boolean};

constructor(config: GraphQLUnionTypeConfig<*, *>) {
constructor(config: GraphQLUnionTypeConfig<*, *>): void {
assertValidName(config.name);
this.name = config.name;
this.description = config.description;
Expand Down Expand Up @@ -888,7 +888,7 @@ export class GraphQLEnumType/* <T> */ {
_valueLookup: Map<any/* T */, GraphQLEnumValue>;
_nameLookup: { [valueName: string]: GraphQLEnumValue };

constructor(config: GraphQLEnumTypeConfig/* <T> */) {
constructor(config: GraphQLEnumTypeConfig/* <T> */): void {
this.name = config.name;
assertValidName(config.name, config.isIntrospection);
this.description = config.description;
Expand Down Expand Up @@ -1067,7 +1067,7 @@ export class GraphQLInputObjectType {
_typeConfig: GraphQLInputObjectTypeConfig;
_fields: GraphQLInputFieldMap;

constructor(config: GraphQLInputObjectTypeConfig) {
constructor(config: GraphQLInputObjectTypeConfig): void {
assertValidName(config.name);
this.name = config.name;
this.description = config.description;
Expand Down Expand Up @@ -1176,7 +1176,7 @@ export type GraphQLInputFieldMap = {
export class GraphQLList<T: GraphQLType> {
ofType: T;

constructor(type: T) {
constructor(type: T): void {
invariant(
isType(type),
`Can only create List of a GraphQLType but got: ${String(type)}.`
Expand Down Expand Up @@ -1221,7 +1221,7 @@ GraphQLList.prototype.toJSON =
export class GraphQLNonNull<T: GraphQLNullableType> {
ofType: T;

constructor(type: T) {
constructor(type: T): void {
invariant(
isType(type) && !(type instanceof GraphQLNonNull),
'Can only create NonNull of a Nullable GraphQLType but got: ' +
Expand Down
2 changes: 1 addition & 1 deletion src/type/directives.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class GraphQLDirective {
locations: Array<DirectiveLocationEnum>;
args: Array<GraphQLArgument>;

constructor(config: GraphQLDirectiveConfig) {
constructor(config: GraphQLDirectiveConfig): void {
invariant(config.name, 'Directive must be named.');
assertValidName(config.name);
invariant(
Expand Down
2 changes: 1 addition & 1 deletion src/type/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class GraphQLSchema {
[abstractName: string]: { [possibleName: string]: boolean }
};

constructor(config: GraphQLSchemaConfig) {
constructor(config: GraphQLSchemaConfig): void {
invariant(
typeof config === 'object',
'Must provide configuration object.'
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/TypeInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class TypeInfo {
// to support non-spec-compliant codebases. You should never need to use it.
// It may disappear in the future.
getFieldDefFn?: typeof getFieldDef
) {
): void {
this._schema = schema;
this._typeStack = [];
this._parentTypeStack = [];
Expand Down
4 changes: 2 additions & 2 deletions src/utilities/extendSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -441,10 +441,10 @@ export function extendSchema(

function extendFieldType<T: GraphQLType>(typeDef: T): T {
if (typeDef instanceof GraphQLList) {
return new GraphQLList(extendFieldType(typeDef.ofType));
return (new GraphQLList(extendFieldType(typeDef.ofType)): any);
}
if (typeDef instanceof GraphQLNonNull) {
return new GraphQLNonNull(extendFieldType(typeDef.ofType));
return (new GraphQLNonNull(extendFieldType(typeDef.ofType)): any);
}
return getTypeFromDef(typeDef);
}
Expand Down
2 changes: 1 addition & 1 deletion src/validation/rules/OverlappingFieldsCanBeMerged.js
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ function subfieldConflicts(
class PairSet {
_data: {[a: string]: {[b: string]: boolean}};

constructor() {
constructor(): void {
this._data = Object.create(null);
}

Expand Down
6 changes: 5 additions & 1 deletion src/validation/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ export class ValidationContext {
_variableUsages: Map<NodeWithSelectionSet, Array<VariableUsage>>;
_recursiveVariableUsages: Map<OperationDefinitionNode, Array<VariableUsage>>;

constructor(schema: GraphQLSchema, ast: DocumentNode, typeInfo: TypeInfo) {
constructor(
schema: GraphQLSchema,
ast: DocumentNode,
typeInfo: TypeInfo
): void {
this._schema = schema;
this._ast = ast;
this._typeInfo = typeInfo;
Expand Down