You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is technically correct, but as users of the library, it doesn't represent the functions we are supposed to write:
17
17
18
18
* If we use the callback approach, we should never return a Promise, and
19
-
* If we do want to write our handler as an async method then
19
+
* If we write an async handler, then
20
20
* The callback parameter shouldn't even exist and
21
21
* The return type should only be a Promise, and not void | Promise
22
22
@@ -31,17 +31,20 @@ Writing tests is now difficult. We get the following types of errors:
31
31
// main.test.ts
32
32
it.('should work', async (done) => {
33
33
34
-
let actual:MyResult=awaitmyHandler(myEvent, myContext); // Expected 3 arguments, but got 2.
35
-
// ^^^ Type 'MyResult | void' is not assignable to type 'MyResult'.
34
+
let actual:MyResult=awaitmyHandler(myEvent, myContext);
35
+
// 1. Expected 3 arguments, but got 2.
36
+
// 2. Type 'MyResult | void' is not assignable to type 'MyResult'.
36
37
});
37
38
```
38
39
40
+
----
41
+
39
42
## The Solution
40
43
41
44
This module exports 2 utility types, `SyncHandler` and `AsyncHandler`, that transform the handlers from [@types/aws-lambda](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/aws-lambda) into the types that are intended to be implemented. It also reexports everything from [@types/aws-lambda](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/aws-lambda) for convenience.
Copy file name to clipboardExpand all lines: package.json
+12-4Lines changed: 12 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,15 @@
1
1
{
2
2
"name": "aws-lambda-consumer",
3
-
"version": "1.0.0-alpha",
4
-
"description": "",
3
+
"version": "1.0.0",
4
+
"description": "Typescript types that transform the handler function types from @types/aws-lambda into the stricter synchronous and asynchronous signatures that are intended to be implemented",
0 commit comments