Skip to content

Commit

Permalink
Use strict top-level tsconfig and fix type issues or override per-pac…
Browse files Browse the repository at this point in the history
…kage
  • Loading branch information
martijnwalraven committed Aug 11, 2018
1 parent 491a858 commit 2369b06
Show file tree
Hide file tree
Showing 29 changed files with 96 additions and 182 deletions.
12 changes: 2 additions & 10 deletions packages/apollo-cache-control/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,8 @@
"extends": "../../tsconfig",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist",
"removeComments": true,
"strict": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUnusedParameters": true,
"noUnusedLocals": true,
"types": ["node"]
"outDir": "./dist"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "**/__tests__/*", "**/__mocks__/*"]
"exclude": ["**/__tests__", "**/__mocks__"]
}
12 changes: 2 additions & 10 deletions packages/apollo-datasource-rest/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,8 @@
"extends": "../../tsconfig",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist",
"removeComments": true,
"strict": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUnusedParameters": true,
"noUnusedLocals": true,
"types": ["node"]
"outDir": "./dist"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "**/__tests__/*", "**/__mocks__/*"]
"exclude": ["**/__tests__", "**/__mocks__"]
}
12 changes: 2 additions & 10 deletions packages/apollo-datasource/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,8 @@
"extends": "../../tsconfig",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist",
"removeComments": true,
"strict": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUnusedParameters": true,
"noUnusedLocals": true,
"types": ["node"]
"outDir": "./dist"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "**/__tests__/*", "**/__mocks__/*"]
"exclude": ["**/__tests__", "**/__mocks__"]
}
2 changes: 1 addition & 1 deletion packages/apollo-engine-reporting-protobuf/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"outDir": "./dist"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "**/__tests__/*", "**/__mocks__/*"]
"exclude": ["**/__tests__", "**/__mocks__"]
}
12 changes: 2 additions & 10 deletions packages/apollo-engine-reporting/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,8 @@
"extends": "../../tsconfig",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist",
"removeComments": true,
"strict": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUnusedParameters": true,
"noUnusedLocals": true,
"types": ["node"]
"outDir": "./dist"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "**/__tests__/*", "**/__mocks__/*"]
"exclude": ["**/__tests__", "**/__mocks__"]
}
13 changes: 8 additions & 5 deletions packages/apollo-server-cache-memcached/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@ import * as Memcached from 'memcached';
import { promisify } from 'util';

export class MemcachedCache implements KeyValueCache {
readonly client;
// FIXME: Replace any with proper promisified type
readonly client: any;
readonly defaultSetOptions = {
ttl: 300,
};

constructor(serverLocation: Memcached.Location, options?: Memcached.options) {
this.client = new Memcached(serverLocation, options);
const client = new Memcached(serverLocation, options);
// promisify client calls for convenience
this.client.get = promisify(this.client.get).bind(this.client);
this.client.set = promisify(this.client.set).bind(this.client);
this.client.flush = promisify(this.client.flush).bind(this.client);
client.get = promisify(client.get).bind(client);
client.set = promisify(client.set).bind(client);
client.flush = promisify(client.flush).bind(client);

this.client = client;
}

async set(
Expand Down
11 changes: 2 additions & 9 deletions packages/apollo-server-cache-memcached/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,8 @@
"extends": "../../tsconfig",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist",
"removeComments": true,
"strict": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUnusedParameters": true,
"noUnusedLocals": true,
"types": ["node"]
"outDir": "./dist"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "**/__tests__/*", "**/__mocks__/*"]
"exclude": ["**/__tests__", "**/__mocks__"]
}
20 changes: 12 additions & 8 deletions packages/apollo-server-cache-redis/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,28 @@ import { promisify } from 'util';
import * as DataLoader from 'dataloader';

export class RedisCache implements KeyValueCache {
readonly client;
// FIXME: Replace any with proper promisified type
readonly client: any;
readonly defaultSetOptions = {
ttl: 300,
};

private loader: DataLoader<string, string>;

constructor(options: Redis.ClientOpts) {
this.client = Redis.createClient(options);
const client = Redis.createClient(options);

// promisify client calls for convenience
client.mget = promisify(client.mget).bind(client);
client.set = promisify(client.set).bind(client);
client.flushdb = promisify(client.flushdb).bind(client);
client.quit = promisify(client.quit).bind(client);

this.client = client;

this.loader = new DataLoader(keys => this.client.mget(keys), {
cache: false,
});

// promisify client calls for convenience
this.client.mget = promisify(this.client.mget).bind(this.client);
this.client.set = promisify(this.client.set).bind(this.client);
this.client.flushdb = promisify(this.client.flushdb).bind(this.client);
this.client.quit = promisify(this.client.quit).bind(this.client);
}

async set(
Expand Down
11 changes: 2 additions & 9 deletions packages/apollo-server-cache-redis/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,8 @@
"extends": "../../tsconfig",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist",
"removeComments": true,
"strict": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUnusedParameters": true,
"noUnusedLocals": true,
"types": ["node"]
"outDir": "./dist"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "**/__tests__/*", "**/__mocks__/*"]
"exclude": ["**/__tests__", "**/__mocks__"]
}
12 changes: 2 additions & 10 deletions packages/apollo-server-caching/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,8 @@
"extends": "../../tsconfig",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist",
"removeComments": true,
"strict": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUnusedParameters": true,
"noUnusedLocals": true,
"types": ["node"]
"outDir": "./dist"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "**/__tests__/*", "**/__mocks__/*"]
"exclude": ["**/__tests__", "**/__mocks__"]
}
8 changes: 1 addition & 7 deletions packages/apollo-server-cloudflare/src/cloudflareApollo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,9 @@ export function graphqlCloudflare(options: GraphQLOptions) {

const res = new Response(error.message, {
status: error.statusCode,
headers: { 'content-type': 'application/json' },
headers: error.headers,
});

if (error.headers) {
Object.keys(error.headers).forEach(header => {
res.headers[header] = error.headers[header];
});
}

return res;
},
);
Expand Down
4 changes: 2 additions & 2 deletions packages/apollo-server-cloudflare/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"extends": "../../tsconfig.json",
"extends": "../../tsconfig",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "**/__tests__/*", "**/__mocks__/*"]
"exclude": ["**/__tests__", "**/__mocks__"]
}
12 changes: 3 additions & 9 deletions packages/apollo-server-core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
{
"extends": "../../tsconfig.json",
"extends": "../../tsconfig",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist",
"strict": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUnusedParameters": true,
"noUnusedLocals": true
"outDir": "./dist"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "**/__tests__/*", "**/__mocks__/*"]
"exclude": ["**/__tests__", "**/__mocks__"]
}
10 changes: 1 addition & 9 deletions packages/apollo-server-env/src/polyfills/Object.values.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
interface ObjectConstructor {
/**
* Returns an array of values of the enumerable properties of an object
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
*/
values<T>(o: { [s: string]: T } | ArrayLike<T>): T[];
}

if (!global.Object.values) {
global.Object.values = function(o) {
global.Object.values = function(o: any) {
return Object.keys(o).map(key => o[key]);
};
}
11 changes: 2 additions & 9 deletions packages/apollo-server-env/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,8 @@
"outDir": "./dist",
"allowJs": true,
"declaration": false,
"declarationMap": false,
"removeComments": true,
"strict": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUnusedParameters": true,
"noUnusedLocals": true
"declarationMap": false
},
"include": ["src/**/*"],
"exclude": ["node_modules", "**/__tests__/*", "**/__mocks__/*"],
"types": []
"exclude": ["**/__tests__", "**/__mocks__"]
}
10 changes: 2 additions & 8 deletions packages/apollo-server-errors/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,8 @@
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist",
"removeComments": true,
"strict": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUnusedParameters": true,
"noUnusedLocals": true,
"types": ["node"]
"noImplicitAny": false
},
"include": ["src/**/*"],
"exclude": ["node_modules", "**/__tests__/*", "**/__mocks__/*"]
"exclude": ["**/__tests__", "**/__mocks__"]
}
7 changes: 4 additions & 3 deletions packages/apollo-server-express/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"extends": "../../tsconfig.json",
"extends": "../../tsconfig",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist",
"lib": ["es2017", "esnext.asynciterable", "dom"]
"noImplicitAny": false,
"strictNullChecks": false
},
"include": ["src/**/*"],
"exclude": ["node_modules", "**/__tests__/*", "**/__mocks__/*"]
"exclude": ["**/__tests__", "**/__mocks__"]
}
8 changes: 5 additions & 3 deletions packages/apollo-server-hapi/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"extends": "../../tsconfig.json",
"extends": "../../tsconfig",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist",
"lib": ["es2017", "esnext.asynciterable", "dom"]
"noImplicitAny": false,
"noImplicitThis": false,
"strictNullChecks": false
},
"include": ["src/**/*"],
"exclude": ["node_modules", "**/__tests__/*", "**/__mocks__/*"]
"exclude": ["**/__tests__", "**/__mocks__"]
}
6 changes: 4 additions & 2 deletions packages/apollo-server-integration-testsuite/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"extends": "../../tsconfig.json",
"extends": "../../tsconfig",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist",
"noImplicitAny": false,
"strictNullChecks": false,
"lib": ["es2017", "esnext.asynciterable", "dom"]
},
"include": ["src/**/*"],
"exclude": ["node_modules", "**/__tests__/*", "**/__mocks__/*"]
"exclude": ["**/__tests__", "**/__mocks__"]
}
8 changes: 5 additions & 3 deletions packages/apollo-server-koa/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"extends": "../../tsconfig.json",
"extends": "../../tsconfig",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist",
"lib": ["es2017", "esnext.asynciterable", "dom"]
"noImplicitAny": false,
"strictNullChecks": false,
"noImplicitReturns": false
},
"include": ["src/**/*"],
"exclude": ["node_modules", "**/__tests__/*", "**/__mocks__/*"]
"exclude": ["**/__tests__", "**/__mocks__"]
}
2 changes: 1 addition & 1 deletion packages/apollo-server-lambda/src/ApolloServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class ApolloServer extends ApolloServerBase {
}

public createHandler({ cors }: CreateHandlerOptions = { cors: undefined }) {
const corsHeaders = {};
const corsHeaders: lambda.APIGatewayProxyResult['headers'] = {};

if (cors) {
if (cors.methods) {
Expand Down
4 changes: 2 additions & 2 deletions packages/apollo-server-lambda/src/lambdaApollo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ export function graphqlLambda(
method: event.httpMethod,
options: options,
query:
event.httpMethod === 'POST'
event.httpMethod === 'POST' && event.body
? JSON.parse(event.body)
: (event.queryStringParameters as any),
: event.queryStringParameters,
request: {
url: event.path,
method: event.httpMethod,
Expand Down
7 changes: 3 additions & 4 deletions packages/apollo-server-lambda/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
"extends": "../../tsconfig.json",
"extends": "../../tsconfig",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist",
"lib": ["es2017", "esnext.asynciterable", "dom"]
"outDir": "./dist"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "**/__tests__/*", "**/__mocks__/*"]
"exclude": ["**/__tests__", "**/__mocks__"]
}
Loading

0 comments on commit 2369b06

Please sign in to comment.