From 79271b044800e92f5186051b21f5c6449b91ec7a Mon Sep 17 00:00:00 2001 From: Omar Diab Date: Tue, 5 Jul 2022 08:04:04 -0400 Subject: [PATCH] Tighter type for message data Instead of being able to shoot yourself in the foot with totally unbounded extra parameters, just provide wildcards for the documented fields that need them. --- lib/interfaces/Messages.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/interfaces/Messages.ts b/lib/interfaces/Messages.ts index 45f07ea7..8eebba8d 100644 --- a/lib/interfaces/Messages.ts +++ b/lib/interfaces/Messages.ts @@ -168,14 +168,12 @@ export type MailgunMessageData = { * to the message ('X-My-Header' in this case). * For example, `h:Reply-To` to specify Reply-To address. */ - 'h:X-My-Header'?: string; + [key: `h:${string}`]: string; /** * `v:` prefix followed by an arbitrary name allows to attach a custom JSON data to the message. See [Attaching Data to Messages](https://documentation.mailgun.com/en/latest/user_manual.html#manual-customdata) for more information. */ - 'v:my-var'?: string; - - [key: string]: any; + [key: `v:${string}`]: string; } export interface MessagesSendAPIResponse {