Skip to content

Commit

Permalink
fix(core): added excplicit typing
Browse files Browse the repository at this point in the history
  • Loading branch information
cjbt committed Sep 13, 2023
1 parent e80e9c2 commit 28f2e1d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/core/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ import {
} from 'aws-lambda'

// extends Handler type from aws-lambda
type ModifyReturnType<T, NewReturn> = T extends (
...args: infer A
type EnhanceHandlerType<T, NewReturn> = T extends (
event: infer TEvent,
context: infer TContextType,
callback: infer TCallbackType
) => infer R
? (...args: A) => R | NewReturn
? (event: TEvent, context: TContextType, callback: TCallbackType) => R | NewReturn
: never

type LambdaHandler<TEvent = any, TResult = any> = ModifyReturnType<AWSLambdaHandler<TEvent, TResult>, TResult>
type LambdaHandler<TEvent = any, TResult = any> = EnhanceHandlerType<AWSLambdaHandler<TEvent, TResult>, TResult>

const lambdaHandler: LambdaHandler<APIGatewayProxyEvent, APIGatewayProxyResult> = async (event) => {
return {
Expand Down

0 comments on commit 28f2e1d

Please sign in to comment.