diff --git a/types/nodemailer/index.d.ts b/types/nodemailer/index.d.ts index 08b42802e5..99a17f3c75 100644 --- a/types/nodemailer/index.d.ts +++ b/types/nodemailer/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Nodemailer 6.2 +// Type definitions for Nodemailer 6.4 // Project: https://github.com/nodemailer/nodemailer, https://nodemailer.com // Definitions by: Rogier Schouten // Piotr Roszatycki diff --git a/types/nodemailer/lib/mime-node/index.d.ts b/types/nodemailer/lib/mime-node/index.d.ts index 5299855ada..6b6fcba05e 100644 --- a/types/nodemailer/lib/mime-node/index.d.ts +++ b/types/nodemailer/lib/mime-node/index.d.ts @@ -87,8 +87,9 @@ declare class MimeNode { */ setContent(content: string | Buffer | Readable): this; - /** Generate the message and return it with a callback */ + /** Generate the message and return it with a callback or promise */ build(callback: (err: Error | null, buf: Buffer) => void): void; + build(): Promise; getTransferEncoding(): string; diff --git a/types/nodemailer/nodemailer-tests.ts b/types/nodemailer/nodemailer-tests.ts index e33a312b6a..7904e123c2 100644 --- a/types/nodemailer/nodemailer-tests.ts +++ b/types/nodemailer/nodemailer-tests.ts @@ -1282,13 +1282,19 @@ function mailcomposer_createReadStream_test() { // build -function mailcomposer_build_test() { +function mailcomposer_build_callback_test() { const mail = new MailComposer({ from: '...' }); mail.compile().build((err, message) => { process.stdout.write(message); }); } +async function mailcomposer_build_promise_test() { + const mail = new MailComposer({ from: '...' }); + const message = await mail.compile().build(); + process.stdout.write(message); +} + // addressparser function isAddress(addressOrGroup: addressparser.AddressOrGroup): addressOrGroup is addressparser.Address {