mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 20:40:20 +00:00
isomorphic-fetch: Just use fetch --lib dom.
This commit is contained in:
Vendored
+4
-112
@@ -2,116 +2,8 @@
|
||||
// Project: https://github.com/matthew-andrews/isomorphic-fetch
|
||||
// Definitions by: Todd Lucas <https://github.com/toddlucas>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
interface ForEachCallback {
|
||||
(keyId: any, status: string): void;
|
||||
}
|
||||
|
||||
interface Headers {
|
||||
append(name: string, value: string): void;
|
||||
delete(name: string): void;
|
||||
forEach(callback: ForEachCallback): void;
|
||||
get(name: string): string | null;
|
||||
has(name: string): boolean;
|
||||
set(name: string, value: string): void;
|
||||
}
|
||||
|
||||
declare var Headers: {
|
||||
prototype: Headers;
|
||||
new(init?: any): Headers;
|
||||
}
|
||||
|
||||
interface Blob {
|
||||
readonly size: number;
|
||||
readonly type: string;
|
||||
msClose(): void;
|
||||
msDetachStream(): any;
|
||||
slice(start?: number, end?: number, contentType?: string): Blob;
|
||||
}
|
||||
|
||||
interface Body {
|
||||
readonly bodyUsed: boolean;
|
||||
arrayBuffer(): Promise<ArrayBuffer>;
|
||||
blob(): Promise<Blob>;
|
||||
json(): Promise<any>;
|
||||
text(): Promise<string>;
|
||||
}
|
||||
|
||||
interface RequestInit {
|
||||
method?: string;
|
||||
headers?: any;
|
||||
body?: any;
|
||||
referrer?: string;
|
||||
referrerPolicy?: string;
|
||||
mode?: string;
|
||||
credentials?: string;
|
||||
cache?: string;
|
||||
redirect?: string;
|
||||
integrity?: string;
|
||||
keepalive?: boolean;
|
||||
window?: any;
|
||||
}
|
||||
|
||||
interface Request extends Object, Body {
|
||||
readonly cache: string;
|
||||
readonly credentials: string;
|
||||
readonly destination: string;
|
||||
readonly headers: Headers;
|
||||
readonly integrity: string;
|
||||
readonly keepalive: boolean;
|
||||
readonly method: string;
|
||||
readonly mode: string;
|
||||
readonly redirect: string;
|
||||
readonly referrer: string;
|
||||
readonly referrerPolicy: string;
|
||||
readonly type: string;
|
||||
readonly url: string;
|
||||
clone(): Request;
|
||||
}
|
||||
|
||||
declare var Request: {
|
||||
prototype: Request;
|
||||
new(input: Request | string, init?: RequestInit): Request;
|
||||
}
|
||||
|
||||
interface ReadableStream {
|
||||
readonly locked: boolean;
|
||||
cancel(): Promise<void>;
|
||||
}
|
||||
|
||||
interface ResponseInit {
|
||||
status?: number;
|
||||
statusText?: string;
|
||||
headers?: any;
|
||||
}
|
||||
|
||||
interface Response extends Object, Body {
|
||||
readonly body: ReadableStream | null;
|
||||
readonly headers: Headers;
|
||||
readonly ok: boolean;
|
||||
readonly status: number;
|
||||
readonly statusText: string;
|
||||
readonly type: string;
|
||||
readonly url: string;
|
||||
clone(): Response;
|
||||
}
|
||||
|
||||
declare var Response: {
|
||||
prototype: Response;
|
||||
new(body?: any, init?: ResponseInit): Response;
|
||||
}
|
||||
|
||||
interface GlobalFetch {
|
||||
fetch(input: Request | string, init?: RequestInit): Promise<Response>;
|
||||
}
|
||||
|
||||
interface Window extends GlobalFetch {
|
||||
}
|
||||
|
||||
declare function fetch(input: Request | string, init?: RequestInit): Promise<Response>;
|
||||
|
||||
declare module "isomorphic-fetch" {
|
||||
namespace _fetch { }
|
||||
const _fetch: typeof fetch;
|
||||
export = _fetch;
|
||||
}
|
||||
declare namespace _fetch { }
|
||||
declare const _fetch: typeof fetch;
|
||||
export = _fetch;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/// <reference types="bluebird" />
|
||||
import fetchImportedViaCommonJS = require('isomorphic-fetch');
|
||||
import * as fetchImportedViaES6Module from 'isomorphic-fetch';
|
||||
|
||||
@@ -35,13 +34,12 @@ function test_isomorphicFetchTestCases_es6() {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function test_whatwgTestCases_ambient() {
|
||||
var headers = new Headers();
|
||||
const headers = new Headers();
|
||||
headers.append("Content-Type", "application/json");
|
||||
var requestOptions: RequestInit = {
|
||||
let requestOptions: RequestInit = {
|
||||
method: "POST",
|
||||
headers: headers,
|
||||
headers,
|
||||
mode: 'same-origin',
|
||||
credentials: 'omit',
|
||||
cache: 'default'
|
||||
@@ -49,7 +47,7 @@ function test_whatwgTestCases_ambient() {
|
||||
|
||||
expectSuccess(fetch('http://localhost:3000/poster', requestOptions), 'Post response:');
|
||||
|
||||
var requestOptions: RequestInit = {
|
||||
requestOptions = {
|
||||
method: "POST",
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
@@ -58,23 +56,23 @@ function test_whatwgTestCases_ambient() {
|
||||
|
||||
expectSuccess(fetch('http://localhost:3000/poster', requestOptions), 'Post response:');
|
||||
|
||||
var requestOptions: RequestInit = {
|
||||
requestOptions = {
|
||||
method: "POST",
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
};
|
||||
var request: Request = new Request('http://localhost:3000/poster', requestOptions);
|
||||
const request: Request = new Request('http://localhost:3000/poster', requestOptions);
|
||||
|
||||
expectSuccess(fetch(request), 'Post response:');
|
||||
}
|
||||
|
||||
function test_whatwgTestCases_commonjs() {
|
||||
var headers = new Headers();
|
||||
const headers = new Headers();
|
||||
headers.append("Content-Type", "application/json");
|
||||
var requestOptions: RequestInit = {
|
||||
let requestOptions: RequestInit = {
|
||||
method: "POST",
|
||||
headers: headers,
|
||||
headers,
|
||||
mode: 'same-origin',
|
||||
credentials: 'omit',
|
||||
cache: 'default'
|
||||
@@ -82,7 +80,7 @@ function test_whatwgTestCases_commonjs() {
|
||||
|
||||
expectSuccess(fetchImportedViaCommonJS('http://localhost:3000/poster', requestOptions), 'Post response:');
|
||||
|
||||
var requestOptions: RequestInit = {
|
||||
requestOptions = {
|
||||
method: "POST",
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
@@ -91,23 +89,23 @@ function test_whatwgTestCases_commonjs() {
|
||||
|
||||
expectSuccess(fetchImportedViaCommonJS('http://localhost:3000/poster', requestOptions), 'Post response:');
|
||||
|
||||
var requestOptions: RequestInit = {
|
||||
requestOptions = {
|
||||
method: "POST",
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
};
|
||||
var request: Request = new Request('http://localhost:3000/poster', requestOptions);
|
||||
const request: Request = new Request('http://localhost:3000/poster', requestOptions);
|
||||
|
||||
expectSuccess(fetchImportedViaCommonJS(request), 'Post response:');
|
||||
}
|
||||
|
||||
function test_whatwgTestCases_es6() {
|
||||
var headers = new Headers();
|
||||
const headers = new Headers();
|
||||
headers.append("Content-Type", "application/json");
|
||||
var requestOptions: RequestInit = {
|
||||
let requestOptions: RequestInit = {
|
||||
method: "POST",
|
||||
headers: headers,
|
||||
headers,
|
||||
mode: 'same-origin',
|
||||
credentials: 'omit',
|
||||
cache: 'default'
|
||||
@@ -115,7 +113,7 @@ function test_whatwgTestCases_es6() {
|
||||
|
||||
expectSuccess(fetchImportedViaES6Module('http://localhost:3000/poster', requestOptions), 'Post response:');
|
||||
|
||||
var requestOptions: RequestInit = {
|
||||
requestOptions = {
|
||||
method: "POST",
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
@@ -124,13 +122,13 @@ function test_whatwgTestCases_es6() {
|
||||
|
||||
expectSuccess(fetchImportedViaES6Module('http://localhost:3000/poster', requestOptions), 'Post response:');
|
||||
|
||||
var requestOptions: RequestInit = {
|
||||
requestOptions = {
|
||||
method: "POST",
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
};
|
||||
var request: Request = new Request('http://localhost:3000/poster', requestOptions);
|
||||
const request: Request = new Request('http://localhost:3000/poster', requestOptions);
|
||||
|
||||
expectSuccess(fetchImportedViaES6Module(request), 'Post response:');
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user