Skip to content

Commit

Permalink
Fixes serverless#17. Allows TypeScript users to benefit from JSON tem…
Browse files Browse the repository at this point in the history
…plate files.
  • Loading branch information
universalhandle committed Mar 8, 2021
1 parent 074ef29 commit e8312ec
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ export const dictionary = {
"aws:websocket": apiGatewayTemplate as APIGatewayEvent, // Websockets are included in APIG typedef: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/32855/files
};

// https://typeofnan.dev/creating-your-own-deeppartial-type-in-typescript/
type DeepPartial<T> = Partial<{ [P in keyof T]: DeepPartial<T[P]> }>;
export default function createEvent<T extends keyof typeof dictionary, B>(
eventType: T,
body: typeof dictionary[T],
body: DeepPartial<typeof dictionary[T]>,
): typeof dictionary[T] {
const event = dictionary[eventType];
let generatedEvent = {};
Expand Down

0 comments on commit e8312ec

Please sign in to comment.