From e8312ec80dd15cf73c27bf5ab5e4d4c30025d899 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20J=2E=20G=C3=B3mez?= Date: Mon, 8 Mar 2021 16:57:50 -0500 Subject: [PATCH] Fixes #17. Allows TypeScript users to benefit from JSON template files. --- lib/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/index.ts b/lib/index.ts index c1b4b45..f9f8aaf 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -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 = Partial<{ [P in keyof T]: DeepPartial }>; export default function createEvent( eventType: T, - body: typeof dictionary[T], + body: DeepPartial, ): typeof dictionary[T] { const event = dictionary[eventType]; let generatedEvent = {};