From 4f199da0894470598ae76f0592ba1fbb023b2a34 Mon Sep 17 00:00:00 2001 From: Kostya Misura Date: Thu, 30 Nov 2017 22:38:22 +0200 Subject: [PATCH] extends lambda callback signature to accept primitive types (boolean, number and string) as result --- types/aws-lambda/aws-lambda-tests.ts | 3 +++ types/aws-lambda/index.d.ts | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/types/aws-lambda/aws-lambda-tests.ts b/types/aws-lambda/aws-lambda-tests.ts index ebd31429de..d21f477be0 100644 --- a/types/aws-lambda/aws-lambda-tests.ts +++ b/types/aws-lambda/aws-lambda-tests.ts @@ -294,6 +294,9 @@ function callback(cb: AWSLambda.Callback) { cb(null); cb(error); cb(null, anyObj); + cb(null, b); + cb(null, str); + cb(null, num); } /* Proxy Callback */ diff --git a/types/aws-lambda/index.d.ts b/types/aws-lambda/index.d.ts index 3b9e31f14c..d6b50ff5e6 100644 --- a/types/aws-lambda/index.d.ts +++ b/types/aws-lambda/index.d.ts @@ -9,6 +9,7 @@ // wwwy3y3 // Ishaan Malhi // Daniel Cottone +// Kostya Misura // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -364,7 +365,7 @@ export type CustomAuthorizerHandler = (event: CustomAuthorizerEvent, context: Co * @param error – an optional parameter that you can use to provide results of the failed Lambda function execution. * @param result – an optional parameter that you can use to provide the result of a successful function execution. The result provided must be JSON.stringify compatible. */ -export type Callback = (error?: Error | null, result?: object) => void; +export type Callback = (error?: Error | null, result?: object | boolean | number | string) => void; export type ProxyCallback = (error?: Error | null, result?: ProxyResult) => void; export type CustomAuthorizerCallback = (error?: Error | null, result?: AuthResponse) => void;