expose isRedirect method of node-fetch in types

This commit is contained in:
Vinay Bedre
2019-01-30 11:14:05 +01:00
parent cad160cba6
commit d90e56c86f
2 changed files with 13 additions and 1 deletions
+8 -1
View File
@@ -2,6 +2,7 @@
// 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>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
@@ -168,7 +169,13 @@ export type HeaderInit = Headers | string[];
export type BodyInit = ArrayBuffer | ArrayBufferView | NodeJS.ReadableStream | string | URLSearchParams;
export type RequestInfo = string | Request;
export default function fetch(
declare function fetch(
url: string | Request,
init?: RequestInit
): Promise<Response>;
declare namespace fetch {
function isRedirect(code: number): boolean;
}
export default fetch;
+5
View File
@@ -77,3 +77,8 @@ function test_headersRaw() {
const myHeader = 'foo';
headers.raw()[myHeader]; // $ExpectType string[]
}
function test_isRedirect() {
fetch.isRedirect(301);
fetch.isRedirect(201);
}