Skip to content

Commit fb82318

Browse files
committed
FIXED: Build breaks because of the nullable Error parameters detected by the TypeScript compiler.
1 parent 142551b commit fb82318

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

shared/api.interfaces.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { APIGatewayEvent, Context, ProxyCallback, ProxyHandler, ProxyResult } from 'aws-lambda'; // tslint:disable-line no-implicit-dependencies (Using only the type information from the @types package.)
1+
import { APIGatewayEvent, Context, ProxyCallback, ProxyResult } from 'aws-lambda'; // tslint:disable-line no-implicit-dependencies (Using only the type information from the @types package.)
22
import { ErrorResult } from './errors';
33

44
// Type aliases to hide the 'aws-lambda' package and have consistent, short naming.
55
export type ApiCallback = ProxyCallback;
66
export type ApiContext = Context;
77
export type ApiEvent = APIGatewayEvent;
8-
export type ApiHandler = ProxyHandler;
8+
export type ApiHandler = (event: APIGatewayEvent, context: Context, callback: ApiCallback) => void; // Same as ProxyHandler, but requires callback.
99
export type ApiResponse = ProxyResult;
1010

1111
export interface ErrorResponseBody {

src/health/health.controller.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ describe('HealthController', () => {
6868
};
6969
}
7070

71-
handler(event, <ApiContext> {}, (error?: Error, result?: ApiResponse): void => {
71+
handler(event, <ApiContext> {}, (error?: Error | null, result?: ApiResponse): void => {
7272
if (typeof result === 'undefined') {
7373
reject('No result was returned by the handler!');
7474
return;

src/swagger/swagger.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class SwaggerService {
3131
const version: string = <string> this._env.API_INFO_VERSION;
3232

3333
return this._repo.getRestApiId(stageName, restApiName)
34-
.then((restApiId: string) => {
34+
.then((restApiId: string | undefined) => {
3535
if (!restApiId) {
3636
throw new NotFoundResult(ErrorCode.InvalidName, 'Cannot find the API with the specified name!');
3737
}

test/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const callSuccess: SuccessCaller = <T>(handler: ApiHandler, pathParameter
1313
event.pathParameters = pathParameters;
1414
}
1515

16-
handler(event, <ApiContext> {}, (error?: Error, result?: ApiResponse): void => {
16+
handler(event, <ApiContext> {}, (error?: Error | null, result?: ApiResponse): void => {
1717
if (typeof result === 'undefined') {
1818
reject('No result was returned by the handler!');
1919
return;
@@ -35,7 +35,7 @@ export const callFailure: FailureCaller = (handler: ApiHandler, pathParameters?:
3535
event.pathParameters = pathParameters;
3636
}
3737

38-
handler(event, <ApiContext> {}, (error?: Error, result?: ApiResponse): void => {
38+
handler(event, <ApiContext> {}, (error?: Error | null, result?: ApiResponse): void => {
3939
if (typeof result === 'undefined') {
4040
reject('No result was returned by the handler!');
4141
return;

0 commit comments

Comments
 (0)