Skip to content

Commit

Permalink
[node-fetch] Fix interable members (were wrongly typed to Iterator) (
Browse files Browse the repository at this point in the history
…DefinitelyTyped#44147)

* [node-fetch] Switch to strict mode, drop unnecessary ES5 lib

* [node-fetch] Fix interable members (were wrongly typed to `Iterator`)
  • Loading branch information
ulrichb authored Apr 23, 2020
1 parent cd367bc commit 839738b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
8 changes: 4 additions & 4 deletions types/node-fetch/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ export class Headers implements Iterable<[string, string]> {
raw(): { [k: string]: string[] };
set(name: string, value: string): void;

// Iterator methods
entries(): Iterator<[string, string]>;
keys(): Iterator<string>;
values(): Iterator<[string]>;
// Iterable methods
entries(): IterableIterator<[string, string]>;
keys(): IterableIterator<string>;
values(): IterableIterator<[string]>;
[Symbol.iterator](): Iterator<[string, string]>;
}

Expand Down
7 changes: 6 additions & 1 deletion types/node-fetch/node-fetch-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,15 @@ function handlePromise(
});
}

function test_headersRaw() {
function test_headers() {
const headers = new Headers();
const myHeader = "foo";
headers.raw()[myHeader]; // $ExpectType string[]

[...headers]; // $ExpectType [string, string][]
[...headers.entries()]; // $ExpectType [string, string][]
[...headers.keys()]; // $ExpectType string[]
[...headers.values()]; // $ExpectType [string][]
}

function test_isRedirect() {
Expand Down
7 changes: 2 additions & 5 deletions types/node-fetch/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "ES6",
"lib": [
"es5",
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strict": true,
"baseUrl": "../",
"typeRoots": [
"../"
Expand Down

0 comments on commit 839738b

Please sign in to comment.