mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
node-fetch: allow agent to accept a function returning Agent (#36057)
* Allow Agent to accept a function * Fix types * string -> URL * Update index.d.ts
This commit is contained in:
parent
17717b3957
commit
49e9bf98b3
5
types/node-fetch/index.d.ts
vendored
5
types/node-fetch/index.d.ts
vendored
@ -7,12 +7,13 @@
|
||||
// Andrew Leedham <https://github.com/AndrewLeedham>
|
||||
// Jason Li <https://github.com/JasonLi914>
|
||||
// Brandon Wilson <https://github.com/wilsonianb>
|
||||
// Steve Faulkner <https://github.com/southpolesteve>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
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;
|
||||
|
||||
@ -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));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user