From 59a842d0ba16e44e8f471b3cf1164806d637c879 Mon Sep 17 00:00:00 2001 From: Alexander Rusakov Date: Tue, 15 Sep 2015 15:24:25 +0300 Subject: [PATCH] whatwg-fetch uses strings and enums --- whatwg-fetch/whatwg-fetch-tests.ts | 8 +++++++- whatwg-fetch/whatwg-fetch.d.ts | 16 ++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/whatwg-fetch/whatwg-fetch-tests.ts b/whatwg-fetch/whatwg-fetch-tests.ts index 5248f5d1dd..a7ba5d05ce 100644 --- a/whatwg-fetch/whatwg-fetch-tests.ts +++ b/whatwg-fetch/whatwg-fetch-tests.ts @@ -6,7 +6,10 @@ function test_fetchUrlWithOptions() { headers.append("Content-Type", "application/json"); var requestOptions: RequestInit = { method: "POST", - headers: headers + headers: headers, + mode: 'same-origin', + credentials: 'omit', + cache: 'default' }; handlePromise(window.fetch("http://www.andlabs.net/html5/uCOR.php", requestOptions)); } @@ -27,6 +30,9 @@ function test_fetchUrl() { function handlePromise(promise: Promise) { promise.then((response) => { + if (response.type === 'basis') { + // for test only + } return response.text(); }).then((text) => { console.log(text); diff --git a/whatwg-fetch/whatwg-fetch.d.ts b/whatwg-fetch/whatwg-fetch.d.ts index 9efd039b4c..f98fb59850 100644 --- a/whatwg-fetch/whatwg-fetch.d.ts +++ b/whatwg-fetch/whatwg-fetch.d.ts @@ -10,20 +10,20 @@ declare class Request { method: string; url: string; headers: Headers; - context: RequestContext; + context: string|RequestContext; referrer: string; - mode: RequestMode; - credentials: RequestCredentials; - cache: RequestCache; + mode: string|RequestMode; + credentials: string|RequestCredentials; + cache: string|RequestCache; } interface RequestInit { method?: string; headers?: HeaderInit|{ [index: string]: string }; body?: BodyInit; - mode?: RequestMode; - credentials?: RequestCredentials; - cache?: RequestCache; + mode?: string|RequestMode; + credentials?: string|RequestCredentials; + cache?: string|RequestCache; } declare enum RequestContext { @@ -58,7 +58,7 @@ declare class Response extends Body { constructor(body?: BodyInit, init?: ResponseInit); error(): Response; redirect(url: string, status: number): Response; - type: ResponseType; + type: string|ResponseType; url: string; status: number; ok: boolean;