diff --git a/types/node-fetch/index.d.ts b/types/node-fetch/index.d.ts index f35c13f2a0..3e73ccd8bd 100644 --- a/types/node-fetch/index.d.ts +++ b/types/node-fetch/index.d.ts @@ -7,12 +7,13 @@ // Andrew Leedham // Jason Li // Brandon Wilson +// Steve Faulkner // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// import { Agent } from "http"; -import { URLSearchParams } from "url"; +import { URLSearchParams, URL } from "url"; import { AbortSignal } from "./externals"; export class Request extends Body { @@ -26,7 +27,7 @@ export class Request extends Body { url: string; // node-fetch extensions to the whatwg/fetch spec - agent?: Agent; + agent?: Agent | ((parsedUrl: URL) => Agent); compress: boolean; counter: number; follow: number; diff --git a/types/node-fetch/node-fetch-tests.ts b/types/node-fetch/node-fetch-tests.ts index 3f42000022..69ad406e62 100644 --- a/types/node-fetch/node-fetch-tests.ts +++ b/types/node-fetch/node-fetch-tests.ts @@ -6,6 +6,7 @@ import fetch, { Response, FetchError } from "node-fetch"; +import { URL } from "url"; import { Agent } from "http"; function test_fetchUrlWithOptions() { @@ -73,7 +74,7 @@ function test_fetchUrlWithRequestObject() { ); const timeout: number = request.timeout; const size: number = request.size; - const agent: Agent | undefined = request.agent; + const agent: Agent | ((parsedUrl: URL) => Agent) | undefined = request.agent; const protocol: string = request.protocol; handlePromise(fetch(request));