Skip to content

Commit

Permalink
fix: require in TS at least 1 type of content for sending mail (#1041)
Browse files Browse the repository at this point in the history
  • Loading branch information
childish-sambino authored Feb 21, 2020
1 parent fa601c7 commit ce5707a
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/mail/src/mail.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import Client = require("@sendgrid/client");
import {ClientResponse} from "@sendgrid/client/src/response";
import {ResponseError} from "@sendgrid/helpers/classes";
import {MailData} from "@sendgrid/helpers/classes/mail";
import {MailContent, MailData} from "@sendgrid/helpers/classes/mail";

type MailDataRequired = MailData & (
{ text: string } | { html: string } | { content: MailContent[] & { 0: MailContent } });

declare class MailService {
/**
Expand All @@ -17,18 +19,18 @@ declare class MailService {
/**
* Send email
*/
send(data: MailData, isMultiple?: boolean, cb?: (err: Error|ResponseError, result: [ClientResponse, {}]) => void): Promise<[ClientResponse, {}]>;
send(data: MailDataRequired, isMultiple?: boolean, cb?: (err: Error | ResponseError, result: [ClientResponse, {}]) => void): Promise<[ClientResponse, {}]>;

/**
* Send emails
*/
send(data: MailData[], isMultiple?: boolean, cb?: (err: Error|ResponseError, result: [ClientResponse, {}]) => void): Promise<[ClientResponse, {}]>;
send(data: MailDataRequired[], isMultiple?: boolean, cb?: (err: Error | ResponseError, result: [ClientResponse, {}]) => void): Promise<[ClientResponse, {}]>;

/**
* Send multiple emails (shortcut)
*/
sendMultiple(data: MailData, cb?: (error: Error|ResponseError, result: [ClientResponse, {}]) => void): Promise<[ClientResponse, {}]>;
sendMultiple(data: MailDataRequired, cb?: (error: Error | ResponseError, result: [ClientResponse, {}]) => void): Promise<[ClientResponse, {}]>;
}

declare const mail: MailService & { MailService: typeof MailService }
declare const mail: MailService & { MailService: typeof MailService };
export = mail

0 comments on commit ce5707a

Please sign in to comment.