node-fetch: correct Headers.raw type (#27364)

* `node-fetch`: add test for `Headers.raw`

* `node-fetch`: `Headers.raw`: add `string[]` to index signature value type

* `node-fetch`: `Headers.raw`: add `undefined` to index signature value type

* `node-fetch`: enable `strictNullChecks` and fix errors

* Revert "`node-fetch`: `Headers.raw`: add `undefined` to index signature value type"

This reverts commit 15ad14d72c42fa1f3ba472bc15f38a88230f3a4f.

* Fix expect type format

* Remove string
This commit is contained in:
Oliver Joseph Ash
2018-07-20 18:01:15 -07:00
committed by Wesley Wigham
parent b7ba5e828b
commit aee338f484
3 changed files with 9 additions and 3 deletions
+1 -1
View File
@@ -102,7 +102,7 @@ export class Headers implements Iterable<[string, string]> {
get(name: string): string | null;
getAll(name: string): string[];
has(name: string): boolean;
raw(): { [k: string]: string };
raw(): { [k: string]: string[] };
set(name: string, value: string): void;
// Iterator methods
+7 -1
View File
@@ -44,7 +44,7 @@ function test_fetchUrlWithRequestObject() {
const request: Request = new Request("http://www.andlabs.net/html5/uCOR.php", requestOptions);
const timeout: number = request.timeout;
const size: number = request.size;
const agent: Agent = request.agent;
const agent: Agent | undefined = request.agent;
const protocol: string = request.protocol;
handlePromise(fetch(request));
@@ -71,3 +71,9 @@ function handlePromise(promise: Promise<Response>, isArrayBuffer: boolean = fals
console.log(text);
});
}
function test_headersRaw() {
const headers = new Headers();
const myHeader = 'foo';
headers.raw()[myHeader]; // $ExpectType string[]
}
+1 -1
View File
@@ -7,7 +7,7 @@
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [