Skip to content

Commit

Permalink
enable strict mode
Browse files Browse the repository at this point in the history
  • Loading branch information
saihaj committed Jul 10, 2021
1 parent e50f9ec commit 9b98bda
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/__tests__/starWarsData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* JSON objects in a more complex demo.
*/

interface Ship {
export interface Ship {
id: string;
name: string;
}
Expand All @@ -25,7 +25,7 @@ const allShips: Array<Ship> = [
{ id: '8', name: 'Executor' },
];

interface Faction {
export interface Faction {
id: string;
name: string;
ships: Array<string>;
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/starWarsSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ const { nodeInterface, nodeField } = nodeDefinitions(
* name: String
* }
*/
const shipType = new GraphQLObjectType({
const shipType: GraphQLObjectType = new GraphQLObjectType({
name: 'Ship',
description: 'A ship in the Star Wars saga',
interfaces: [nodeInterface],
Expand Down Expand Up @@ -171,7 +171,7 @@ const { connectionType: shipConnection } = connectionDefinitions({
* ships: ShipConnection
* }
*/
const factionType = new GraphQLObjectType({
const factionType: GraphQLObjectType = new GraphQLObjectType({
name: 'Faction',
description: 'A faction in the Star Wars saga',
interfaces: [nodeInterface],
Expand Down
2 changes: 1 addition & 1 deletion src/connection/__tests__/connection-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const allUsers = [
{ name: 'Tim', friends: [0, 1, 2, 3] },
];

const userType = new GraphQLObjectType({
const userType: GraphQLObjectType = new GraphQLObjectType({
name: 'User',
fields: () => ({
name: {
Expand Down
9 changes: 6 additions & 3 deletions src/connection/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@ export interface ForwardConnectionArgs {
* Returns a GraphQLFieldConfigArgumentMap appropriate to include on a field
* whose return type is a connection type with forward pagination.
*/
export const forwardConnectionArgs:
| ForwardConnectionArgs
| GraphQLFieldConfigArgumentMap = {
export const forwardConnectionArgs: ForwardConnectionArgs &
GraphQLFieldConfigArgumentMap = {
after: {
type: GraphQLString,
// @ts-expect-error FIXME
description:
'Returns the items in the list that come after the specified cursor.',
},
first: {
type: GraphQLInt,
// @ts-expect-error FIXME
description: 'Returns the first n items from the list.',
},
};
Expand All @@ -53,11 +54,13 @@ export const backwardConnectionArgs: BackwardConnectionArgs &
GraphQLFieldConfigArgumentMap = {
before: {
type: GraphQLString,
// @ts-expect-error FIXME
description:
'Returns the items in the list that come before the specified cursor.',
},
last: {
type: GraphQLInt,
// @ts-expect-error FIXME
description: 'Returns the last n items from the list.',
},
};
Expand Down
1 change: 1 addition & 0 deletions src/mutation/type.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module 'graphql/jsutils/isPromise';
6 changes: 3 additions & 3 deletions src/node/__tests__/global-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const { nodeField, nodeInterface } = nodeDefinitions(
},
);

const userType = new GraphQLObjectType({
const userType: GraphQLObjectType = new GraphQLObjectType({
name: 'User',
interfaces: [nodeInterface],
fields: () => ({
Expand All @@ -83,7 +83,7 @@ const userType = new GraphQLObjectType({
}),
});

const photoType = new GraphQLObjectType({
const photoType: GraphQLObjectType = new GraphQLObjectType({
name: 'Photo',
interfaces: [nodeInterface],
fields: () => ({
Expand All @@ -94,7 +94,7 @@ const photoType = new GraphQLObjectType({
}),
});

const postType = new GraphQLObjectType({
const postType: GraphQLObjectType = new GraphQLObjectType({
name: 'Post',
interfaces: [nodeInterface],
fields: () => ({
Expand Down
4 changes: 2 additions & 2 deletions src/node/__tests__/node-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const { nodeField, nodesField, nodeInterface } = nodeDefinitions(
},
);

const userType = new GraphQLObjectType({
const userType: GraphQLObjectType = new GraphQLObjectType({
name: 'User',
interfaces: [nodeInterface],
fields: () => ({
Expand All @@ -70,7 +70,7 @@ const userType = new GraphQLObjectType({
}),
});

const photoType = new GraphQLObjectType({
const photoType: GraphQLObjectType = new GraphQLObjectType({
name: 'Photo',
interfaces: [nodeInterface],
fields: () => ({
Expand Down
2 changes: 1 addition & 1 deletion src/node/__tests__/nodeAsync-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const { nodeField, nodeInterface } = nodeDefinitions(
() => userType,
);

const userType = new GraphQLObjectType({
const userType: GraphQLObjectType = new GraphQLObjectType({
name: 'User',
interfaces: [nodeInterface],
fields: () => ({
Expand Down
6 changes: 3 additions & 3 deletions src/node/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function nodeDefinitions<TContext>(
resolveType: typeResolver,
});

const nodeField = {
const nodeField: GraphQLFieldConfig<unknown, TContext> = {
description: 'Fetches an object given its ID',
type: nodeInterface,
args: {
Expand All @@ -61,7 +61,7 @@ export function nodeDefinitions<TContext>(
resolve: (_obj, { id }, context, info) => fetchById(id, context, info),
};

const nodesField = {
const nodesField: GraphQLFieldConfig<unknown, TContext> = {
description: 'Fetches objects given their IDs',
type: new GraphQLNonNull(new GraphQLList(nodeInterface)),
args: {
Expand All @@ -73,7 +73,7 @@ export function nodeDefinitions<TContext>(
},
},
resolve: (_obj, { ids }, context, info) =>
ids.map((id) => fetchById(id, context, info)),
ids.map((id: string) => fetchById(id, context, info)),
};

return { nodeInterface, nodeField, nodesField };
Expand Down
2 changes: 1 addition & 1 deletion src/node/plural.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function pluralIdentifyingRootField(
},
resolve(_obj, args, context, info) {
const inputs = args[config.argName];
return inputs.map((input) =>
return inputs.map((input: unknown) =>
config.resolveSingleInput(input, context, info),
);
},
Expand Down
3 changes: 2 additions & 1 deletion src/utils/base64.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ function fromBase64Char(base64Char: string | undefined): number {
function stringToUTF8Array(input: string): Array<number> {
const result = [];
for (const utfChar of input) {
const code = utfChar.codePointAt(0);
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const code = utfChar.codePointAt(0)!;
if (code < 0x80) {
result.push(code);
} else if (code < 0x800) {
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": false,
"strict": true,
"noEmit": true,
"isolatedModules": true,
"forceConsistentCasingInFileNames": true
Expand Down

0 comments on commit 9b98bda

Please sign in to comment.