Skip to content

Commit

Permalink
TS: Enable strict mode
Browse files Browse the repository at this point in the history
  • Loading branch information
leebyron committed May 27, 2021
1 parent 69b4c59 commit bf26a52
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 29 deletions.
4 changes: 2 additions & 2 deletions src/error/__tests__/formatError-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ describe('formatError: default error formatter', () => {
});

it('rejects null and undefined errors', () => {
// TODO ts-expect-error (formatError expects a value)
// @ts-expect-error (formatError expects a value)
expect(() => formatError(undefined)).to.throw(
'Received null or undefined error.',
);

// TODO ts-expect-error (formatError expects a value)
// @ts-expect-error (formatError expects a value)
expect(() => formatError(null)).to.throw(
'Received null or undefined error.',
);
Expand Down
6 changes: 3 additions & 3 deletions src/execution/__tests__/abstract-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -577,9 +577,9 @@ describe('Execute: Handles execution of abstract types', () => {
);

// FIXME: workaround since we can't inject resolveType into SDL
assertInterfaceType(schema.getType('Pet')).resolveType =
// @ts-expect-error
() => schema.getType('Cat');
// @ts-expect-error
assertInterfaceType(schema.getType('Pet')).resolveType = () =>
schema.getType('Cat');
expectError({ forTypeName: undefined }).toEqual(
'Support for returning GraphQLObjectType from resolveType was removed in graphql-js@16.0.0 please return type name instead.',
);
Expand Down
2 changes: 1 addition & 1 deletion src/language/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export class Token {
this.end = end;
this.line = line;
this.column = column;
this.value = value;
this.value = value as string;
this.prev = prev;
this.next = null;
}
Expand Down
4 changes: 2 additions & 2 deletions src/subscription/__tests__/subscribe-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ describe('Subscription Initialization Phase', () => {
}),
});

// TODO ts-expect-error (schema must not be null)
// @ts-expect-error (schema must not be null)
(await expectPromise(subscribe({ schema: null, document }))).toRejectWith(
'Expected null to be a GraphQL schema.',
);
Expand All @@ -323,7 +323,7 @@ describe('Subscription Initialization Phase', () => {
'Expected undefined to be a GraphQL schema.',
);

// TODO ts-expect-error (document must not be null)
// @ts-expect-error (document must not be null)
(await expectPromise(subscribe({ schema, document: null }))).toRejectWith(
'Must provide document.',
);
Expand Down
1 change: 0 additions & 1 deletion src/subscription/mapAsyncIterator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export function mapAsyncIterator<T, U, R = undefined>(
}

try {
// @ts-expect-error FIXME: TS Conversion
return { value: await callback(result.value), done: false };
} catch (error) {
// istanbul ignore else (FIXME: add test case)
Expand Down
12 changes: 6 additions & 6 deletions src/type/__tests__/definition-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ describe('Type System: Objects', () => {
const objType = new GraphQLObjectType({
name: 'SomeObject',
fields: {
// TODO ts-expect-error (must not be undefined)
// @ts-expect-error (must not be undefined)
f: undefined,
},
});
Expand Down Expand Up @@ -697,7 +697,7 @@ describe('Type System: Enums', () => {
() =>
new GraphQLEnumType({
name: 'SomeEnum',
// TODO ts-expect-error (must not be null)
// @ts-expect-error (must not be null)
values: { FOO: null },
}),
).to.throw(
Expand Down Expand Up @@ -843,9 +843,9 @@ describe('Type System: List', () => {
expectList(String).to.throw(
'Expected [function String] to be a GraphQL type.',
);
// TODO ts-expect-error (must provide type)
// @ts-expect-error (must provide type)
expectList(null).to.throw('Expected null to be a GraphQL type.');
// TODO ts-expect-error (must provide type)
// @ts-expect-error (must provide type)
expectList(undefined).to.throw('Expected undefined to be a GraphQL type.');
});
});
Expand Down Expand Up @@ -876,11 +876,11 @@ describe('Type System: Non-Null', () => {
expectNonNull(String).to.throw(
'Expected [function String] to be a GraphQL nullable type.',
);
// TODO ts-expect-error (must provide type)
// @ts-expect-error (must provide type)
expectNonNull(null).to.throw(
'Expected null to be a GraphQL nullable type.',
);
// TODO ts-expect-error (must provide type)
// @ts-expect-error (must provide type)
expectNonNull(undefined).to.throw(
'Expected undefined to be a GraphQL nullable type.',
);
Expand Down
10 changes: 5 additions & 5 deletions src/type/__tests__/validation-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ describe('Type System: Object fields must have output types', () => {
}

it('rejects an empty Object field type', () => {
// TODO ts-expect-error (type field must not be undefined)
// @ts-expect-error (type field must not be undefined)
const schema = schemaWithObjectField({ type: undefined });
expect(validateSchema(schema)).to.deep.equal([
{
Expand Down Expand Up @@ -1098,7 +1098,7 @@ describe('Type System: Objects can only implement unique interfaces', () => {
const schema = new GraphQLSchema({
query: new GraphQLObjectType({
name: 'BadObject',
// TODO ts-expect-error (interfaces must not contain undefined)
// @ts-expect-error (interfaces must not contain undefined)
interfaces: [undefined],
fields: { f: { type: GraphQLString } },
}),
Expand Down Expand Up @@ -1357,7 +1357,7 @@ describe('Type System: Interface fields must have output types', () => {
}

it('rejects an empty Interface field type', () => {
// TODO ts-expect-error (type field must not be undefined)
// @ts-expect-error (type field must not be undefined)
const schema = schemaWithInterfaceField({ type: undefined });
expect(validateSchema(schema)).to.deep.equal([
{
Expand Down Expand Up @@ -1493,7 +1493,7 @@ describe('Type System: Arguments must have input types', () => {
}

it('rejects an empty field arg type', () => {
// TODO ts-expect-error (type field must not be undefined)
// @ts-expect-error (type field must not be undefined)
const schema = schemaWithArg({ type: undefined });
expect(validateSchema(schema)).to.deep.equal([
{
Expand Down Expand Up @@ -1631,7 +1631,7 @@ describe('Type System: Input Object fields must have input types', () => {
}

it('rejects an empty input field type', () => {
// TODO ts-expect-error (type field must not be undefined)
// @ts-expect-error (type field must not be undefined)
const schema = schemaWithInputField({ type: undefined });
expect(validateSchema(schema)).to.deep.equal([
{
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/__tests__/buildASTSchema-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,7 @@ describe('Schema Builder', () => {
});

it('Rejects invalid AST', () => {
// TODO ts-expect-error (First parameter expected to be DocumentNode)
// @ts-expect-error (First parameter expected to be DocumentNode)
expect(() => buildASTSchema(null)).to.throw(
'Must provide valid Document AST',
);
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/__tests__/buildClientSchema-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ describe('Type System: build schema from introspection', () => {
`);

it('throws when introspection is missing __schema property', () => {
// TODO ts-expect-error (First parameter expected to be introspection results)
// @ts-expect-error (First parameter expected to be introspection results)
expect(() => buildClientSchema(null)).to.throw(
'Invalid or incomplete introspection result. Ensure that you are passing "data" property of introspection response and no "errors" was returned alongside: null.',
);
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/__tests__/extendSchema-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@ describe('extendSchema', () => {
it('Rejects invalid AST', () => {
const schema = new GraphQLSchema({});

// TODO ts-expect-error (Second argument expects DocumentNode)
// @ts-expect-error (Second argument expects DocumentNode)
expect(() => extendSchema(schema, null)).to.throw(
'Must provide valid Document AST',
);
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/extendSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ export function extendSchemaImpl(
// Note: While this could make early assertions to get the correctly
// typed values below, that would throw immediately while type system
// validation with validateSchema() will produce more actionable results.
// TODO ts-expect-error
// @ts-expect-error
opTypes[operationType.operation] = getNamedType(operationType.type);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/validation/__tests__/validation-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { testSchema } from './harness';

describe('Validate: Supports full validation', () => {
it('rejects invalid documents', () => {
// TODO ts-expect-error (expects a DocumentNode as a second parameter)
// @ts-expect-error (expects a DocumentNode as a second parameter)
expect(() => validate(testSchema, null)).to.throw('Must provide document.');
});

Expand Down
5 changes: 1 addition & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
"module": "commonjs",
"lib": ["es2019", "es2020.promise", "es2020.bigint", "es2020.string"],
"target": "es2019",
"noImplicitAny": false,
"noImplicitThis": false,
"strictNullChecks": false,
"strictFunctionTypes": true,
"strict": true,
"noEmit": true,
"forceConsistentCasingInFileNames": true
}
Expand Down

0 comments on commit bf26a52

Please sign in to comment.