diff --git a/types/nodemailer/lib/fetch/index.d.ts b/types/nodemailer/lib/fetch/index.d.ts index 8fc814c517..765debb179 100644 --- a/types/nodemailer/lib/fetch/index.d.ts +++ b/types/nodemailer/lib/fetch/index.d.ts @@ -4,12 +4,18 @@ type ms = number; import _Cookies = require('./cookies'); +import * as http from 'http'; import { Writable } from 'stream'; import * as tls from 'tls'; declare namespace fetch { type Cookies = _Cookies; + interface WritableResponse extends Writable { + statusCode: number; + headers: http.IncomingHttpHeaders; + } + interface Options { fetchRes?: Writable; cookies?: Cookies; @@ -27,6 +33,6 @@ declare namespace fetch { } } -declare function fetch(url: string, options?: fetch.Options): Writable; +declare function fetch(url: string, options?: fetch.Options): fetch.WritableResponse; export = fetch; diff --git a/types/nodemailer/nodemailer-tests.ts b/types/nodemailer/nodemailer-tests.ts index 9761cb73e4..db7ba336a8 100644 --- a/types/nodemailer/nodemailer-tests.ts +++ b/types/nodemailer/nodemailer-tests.ts @@ -1090,7 +1090,11 @@ function base64_test() { // fetch function fetch_test() { - fetch('http://localhost/'); + const stream = fetch('http://localhost/'); + + const statusCode: number = stream.statusCode; + const headers = stream.headers; + const contentType: string | undefined = headers['content-type']; fetch('http://localhost:/', { allowErrorResponse: true,