-
Notifications
You must be signed in to change notification settings - Fork 30.6k
node-fetch: restore types (for v2), update version, allow agent: false
#58693
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
typescript-bot
merged 7 commits into
DefinitelyTyped:master
from
glasser:glasser/restore-node-fetch-v2-and-fix-agent-false
Feb 14, 2022
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
613277b
Revert "🤖 Merge PR #55533 Remove node-fetch - not needed as of 3.0.0 …
glasser c0ef341
Update tslint.json for change from #57489
glasser 2766011
node-fetch: update version to 2.6
glasser af88e00
node-fetch: `agent` can be a boolean
glasser 5e1aa5d
Update types/node-fetch/tsconfig.json
glasser 1492eaa
Update types/node-fetch/index.d.ts
glasser 1ac3891
Update types/node-fetch/package.json
glasser File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,6 @@ | ||
| { | ||
| "private": true, | ||
| "dependencies": { | ||
| "@types/node-fetch": "^2.5.12", | ||
| "joi": "^17.3.0" | ||
| } | ||
| } |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // `AbortSignal` is defined here to prevent a dependency on a particular | ||
| // implementation like the `abort-controller` package, and to avoid requiring | ||
| // the `dom` library in `tsconfig.json`. | ||
|
|
||
| export interface AbortSignal { | ||
| aborted: boolean; | ||
|
|
||
| addEventListener: (type: "abort", listener: ((this: AbortSignal, event: any) => any), options?: boolean | { | ||
| capture?: boolean | undefined, | ||
| once?: boolean | undefined, | ||
| passive?: boolean | undefined | ||
| }) => void; | ||
|
|
||
| removeEventListener: (type: "abort", listener: ((this: AbortSignal, event: any) => any), options?: boolean | { | ||
| capture?: boolean | undefined | ||
| }) => void; | ||
|
|
||
| dispatchEvent: (event: any) => boolean; | ||
|
|
||
| onabort: null | ((this: AbortSignal, event: any) => void); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,224 @@ | ||
| // Type definitions for node-fetch 2.6 | ||
| // Project: https://github.com/bitinn/node-fetch | ||
| // Definitions by: Torsten Werner <https://github.com/torstenwerner> | ||
| // Niklas Lindgren <https://github.com/nikcorg> | ||
| // Vinay Bedre <https://github.com/vinaybedre> | ||
| // Antonio Román <https://github.com/kyranet> | ||
| // Andrew Leedham <https://github.com/AndrewLeedham> | ||
| // Jason Li <https://github.com/JasonLi914> | ||
| // Steve Faulkner <https://github.com/southpolesteve> | ||
| // ExE Boss <https://github.com/ExE-Boss> | ||
| // Alex Savin <https://github.com/alexandrusavin> | ||
| // Alexis Tyler <https://github.com/OmgImAlexis> | ||
| // Jakub Kisielewski <https://github.com/kbkk> | ||
| // David Glasser <https://github.com/glasser> | ||
| // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
|
|
||
| /// <reference types="node" /> | ||
|
|
||
| import FormData = require('form-data'); | ||
| import { RequestOptions } from "http"; | ||
| import { URLSearchParams, URL } from "url"; | ||
| import { AbortSignal } from "./externals"; | ||
|
|
||
| export class Request extends Body { | ||
| constructor(input: RequestInfo, init?: RequestInit); | ||
| clone(): Request; | ||
| context: RequestContext; | ||
| headers: Headers; | ||
| method: string; | ||
| redirect: RequestRedirect; | ||
| referrer: string; | ||
| url: string; | ||
|
|
||
| // node-fetch extensions to the whatwg/fetch spec | ||
| agent?: RequestOptions['agent'] | ((parsedUrl: URL) => RequestOptions['agent']); | ||
| compress: boolean; | ||
| counter: number; | ||
| follow: number; | ||
| hostname: string; | ||
| port?: number | undefined; | ||
| protocol: string; | ||
| size: number; | ||
| timeout: number; | ||
| } | ||
|
|
||
| export interface RequestInit { | ||
| // whatwg/fetch standard options | ||
| body?: BodyInit | undefined; | ||
| headers?: HeadersInit | undefined; | ||
| method?: string | undefined; | ||
| redirect?: RequestRedirect | undefined; | ||
| signal?: AbortSignal | null | undefined; | ||
|
|
||
| // node-fetch extensions | ||
| agent?: RequestOptions['agent'] | ((parsedUrl: URL) => RequestOptions['agent']); // =null http.Agent instance, allows custom proxy, certificate etc. | ||
| compress?: boolean | undefined; // =true support gzip/deflate content encoding. false to disable | ||
| follow?: number | undefined; // =20 maximum redirect count. 0 to not follow redirect | ||
| size?: number | undefined; // =0 maximum response body size in bytes. 0 to disable | ||
| timeout?: number | undefined; // =0 req/res timeout in ms, it resets on redirect. 0 to disable (OS limit applies) | ||
|
|
||
| // node-fetch does not support mode, cache or credentials options | ||
| } | ||
|
|
||
| export type RequestContext = | ||
| "audio" | ||
| | "beacon" | ||
| | "cspreport" | ||
| | "download" | ||
| | "embed" | ||
| | "eventsource" | ||
| | "favicon" | ||
| | "fetch" | ||
| | "font" | ||
| | "form" | ||
| | "frame" | ||
| | "hyperlink" | ||
| | "iframe" | ||
| | "image" | ||
| | "imageset" | ||
| | "import" | ||
| | "internal" | ||
| | "location" | ||
| | "manifest" | ||
| | "object" | ||
| | "ping" | ||
| | "plugin" | ||
| | "prefetch" | ||
| | "script" | ||
| | "serviceworker" | ||
| | "sharedworker" | ||
| | "style" | ||
| | "subresource" | ||
| | "track" | ||
| | "video" | ||
| | "worker" | ||
| | "xmlhttprequest" | ||
| | "xslt"; | ||
| export type RequestMode = "cors" | "no-cors" | "same-origin"; | ||
| export type RequestRedirect = "error" | "follow" | "manual"; | ||
| export type RequestCredentials = "omit" | "include" | "same-origin"; | ||
|
|
||
| export type RequestCache = | ||
| "default" | ||
| | "force-cache" | ||
| | "no-cache" | ||
| | "no-store" | ||
| | "only-if-cached" | ||
| | "reload"; | ||
|
|
||
| export class Headers implements Iterable<[string, string]> { | ||
| constructor(init?: HeadersInit); | ||
| forEach(callback: (value: string, name: string) => void): void; | ||
| append(name: string, value: string): void; | ||
| delete(name: string): void; | ||
| get(name: string): string | null; | ||
| has(name: string): boolean; | ||
| raw(): { [k: string]: string[] }; | ||
| set(name: string, value: string): void; | ||
|
|
||
| // Iterable methods | ||
| entries(): IterableIterator<[string, string]>; | ||
| keys(): IterableIterator<string>; | ||
| values(): IterableIterator<string>; | ||
| [Symbol.iterator](): Iterator<[string, string]>; | ||
| } | ||
|
|
||
| type BlobPart = ArrayBuffer | ArrayBufferView | Blob | string; | ||
|
|
||
| interface BlobOptions { | ||
| type?: string | undefined; | ||
| endings?: "transparent" | "native" | undefined; | ||
| } | ||
|
|
||
| export class Blob { | ||
| constructor(blobParts?: BlobPart[], options?: BlobOptions); | ||
| readonly type: string; | ||
| readonly size: number; | ||
| slice(start?: number, end?: number): Blob; | ||
| text(): Promise<string>; | ||
| } | ||
|
|
||
| export class Body { | ||
| constructor(body?: any, opts?: { size?: number | undefined; timeout?: number | undefined }); | ||
| arrayBuffer(): Promise<ArrayBuffer>; | ||
| blob(): Promise<Blob>; | ||
| body: NodeJS.ReadableStream; | ||
| bodyUsed: boolean; | ||
| buffer(): Promise<Buffer>; | ||
| json(): Promise<any>; | ||
| size: number; | ||
| text(): Promise<string>; | ||
| textConverted(): Promise<string>; | ||
| timeout: number; | ||
| } | ||
|
|
||
| interface SystemError extends Error { | ||
| code?: string | undefined; | ||
| } | ||
|
|
||
| export class FetchError extends Error { | ||
| name: "FetchError"; | ||
| constructor(message: string, type: string, systemError?: SystemError); | ||
| type: string; | ||
| code?: string | undefined; | ||
| errno?: string | undefined; | ||
| } | ||
|
|
||
| export class Response extends Body { | ||
| constructor(body?: BodyInit, init?: ResponseInit); | ||
| static error(): Response; | ||
| static redirect(url: string, status: number): Response; | ||
| clone(): Response; | ||
| headers: Headers; | ||
| ok: boolean; | ||
| redirected: boolean; | ||
| status: number; | ||
| statusText: string; | ||
| type: ResponseType; | ||
| url: string; | ||
| } | ||
|
|
||
| export type ResponseType = | ||
| "basic" | ||
| | "cors" | ||
| | "default" | ||
| | "error" | ||
| | "opaque" | ||
| | "opaqueredirect"; | ||
|
|
||
| export interface ResponseInit { | ||
| headers?: HeadersInit | undefined; | ||
| size?: number | undefined; | ||
| status?: number | undefined; | ||
| statusText?: string | undefined; | ||
| timeout?: number | undefined; | ||
| url?: string | undefined; | ||
| } | ||
|
|
||
| interface URLLike { | ||
| href: string; | ||
| } | ||
|
|
||
| export type HeadersInit = Headers | string[][] | { [key: string]: string }; | ||
| // HeaderInit is exported to support backwards compatibility. See PR #34382 | ||
| export type HeaderInit = HeadersInit; | ||
| export type BodyInit = | ||
| ArrayBuffer | ||
| | ArrayBufferView | ||
| | NodeJS.ReadableStream | ||
| | string | ||
| | URLSearchParams | ||
| | FormData; | ||
| export type RequestInfo = string | URLLike | Request; | ||
|
|
||
| declare function fetch( | ||
| url: RequestInfo, | ||
| init?: RequestInit | ||
| ): Promise<Response>; | ||
|
|
||
| declare namespace fetch { | ||
| function isRedirect(code: number): boolean; | ||
| } | ||
|
|
||
| export default fetch; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.