From 215e1ca760325e3924a4df8adf4f94b37afda3cc Mon Sep 17 00:00:00 2001 From: Jonathan Stewmon Date: Thu, 18 Mar 2021 15:30:10 -0500 Subject: [PATCH] add missing Headers interface augmentation from lib.dom.iterable.d.ts declaration files were generated and tested with the following command: npm i --no-save typescript@4.2.3 \ && cat < .ts-graftrc.yaml \ && npx ts-graft@1.0.1 \ && rm .ts-graftrc.yaml \ && npx tsc --lib ES2016 --target ES2016 --noEmit index.d.ts \ && npm un typescript grafts: - source: typescript/lib/lib.dom.d.ts output: lib.fetch.d.ts include: - BodyInit - HeadersInit - RequestInfo - RequestInit - Response - ResponseInit - source: typescript/lib/lib.dom.iterable.d.ts output: lib.fetch.dom.iterable.d.ts include: - Headers EOF --- index.d.ts | 6 ++++-- lib.fetch.iterable.d.ts | 16 ++++++++++++++++ package.json | 3 ++- 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 lib.fetch.iterable.d.ts diff --git a/index.d.ts b/index.d.ts index 0d1c548..865098a 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,6 +1,6 @@ -import { +import type { BodyInit, - Headers, + Headers as BaseHeaders, HeadersInit, Request, RequestInfo, @@ -8,6 +8,8 @@ import { Response, ResponseInit, } from "./lib.fetch" +import type { Headers as IterHeaders } from "./lib.fetch.iterable"; +type Headers = BaseHeaders & IterHeaders; export const fetch: (input: RequestInfo, init?: RequestInit) => Promise; diff --git a/lib.fetch.iterable.d.ts b/lib.fetch.iterable.d.ts new file mode 100644 index 0000000..66639a0 --- /dev/null +++ b/lib.fetch.iterable.d.ts @@ -0,0 +1,16 @@ +// Generated by resolving typescript/lib/lib.dom.iterable.d.ts from typescript@4.2.3 +export interface Headers { + [Symbol.iterator](): IterableIterator<[string, string]>; + /** + * Returns an iterator allowing to go through all key/value pairs contained in this object. + */ + entries(): IterableIterator<[string, string]>; + /** + * Returns an iterator allowing to go through all keys of the key/value pairs contained in this object. + */ + keys(): IterableIterator; + /** + * Returns an iterator allowing to go through all values of the key/value pairs contained in this object. + */ + values(): IterableIterator; +} diff --git a/package.json b/package.json index 60001df..b7a2099 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,8 @@ "dist", "polyfill", "index.d.ts", - "lib.fetch.d.ts" + "lib.fetch.d.ts", + "lib.fetch.iterable.d.ts" ], "keywords": [ "fetch",