From 7a5bc95614ded7fb88ffe2a6967e37871c0ad5d0 Mon Sep 17 00:00:00 2001 From: Fabian Wiles Date: Mon, 31 Jul 2017 18:40:01 +1200 Subject: [PATCH] refactor(http): inline HttpObserve (#18417) Inline `HttpObserve` for better type safety. Fix #18146 PR Close #18417 --- goldens/public-api/common/http/http.d.ts | 2 +- packages/common/http/src/client.ts | 22 ++++++++++------------ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/goldens/public-api/common/http/http.d.ts b/goldens/public-api/common/http/http.d.ts index 83b1daa7b8..0d79d7073b 100644 --- a/goldens/public-api/common/http/http.d.ts +++ b/goldens/public-api/common/http/http.d.ts @@ -1472,7 +1472,7 @@ export declare class HttpClient { params?: HttpParams | { [param: string]: string | string[]; }; - observe?: HttpObserve; + observe?: 'body' | 'events' | 'response'; reportProgress?: boolean; responseType?: 'arraybuffer' | 'blob' | 'json' | 'text'; withCredentials?: boolean; diff --git a/packages/common/http/src/client.ts b/packages/common/http/src/client.ts index cb15e4ee91..10ca8f7b21 100644 --- a/packages/common/http/src/client.ts +++ b/packages/common/http/src/client.ts @@ -30,7 +30,7 @@ import {HttpEvent, HttpResponse} from './response'; function addBody( options: { headers?: HttpHeaders|{[header: string]: string | string[]}, - observe?: HttpObserve, + observe?: 'body'|'events'|'response', params?: HttpParams|{[param: string]: string | string[]}, reportProgress?: boolean, responseType?: 'arraybuffer'|'blob'|'json'|'text', @@ -48,8 +48,6 @@ function addBody( }; } -export type HttpObserve = 'body'|'events'|'response'; - /** * Performs HTTP requests. * This service is available as an injectable class, with methods to perform HTTP requests. @@ -408,7 +406,7 @@ export class HttpClient { body?: any, headers?: HttpHeaders|{[header: string]: string | string[]}, params?: HttpParams|{[param: string]: string | string[]}, - observe?: HttpObserve, + observe?: 'body'|'events'|'response', reportProgress?: boolean, responseType?: 'arraybuffer'|'blob'|'json'|'text', withCredentials?: boolean, @@ -443,7 +441,7 @@ export class HttpClient { request(first: string|HttpRequest, url?: string, options: { body?: any, headers?: HttpHeaders|{[header: string]: string | string[]}, - observe?: HttpObserve, + observe?: 'body'|'events'|'response', params?: HttpParams|{[param: string]: string | string[]}, reportProgress?: boolean, responseType?: 'arraybuffer'|'blob'|'json'|'text', @@ -825,7 +823,7 @@ export class HttpClient { */ delete(url: string, options: { headers?: HttpHeaders|{[header: string]: string | string[]}, - observe?: HttpObserve, + observe?: 'body'|'events'|'response', params?: HttpParams|{[param: string]: string | string[]}, reportProgress?: boolean, responseType?: 'arraybuffer'|'blob'|'json'|'text', @@ -1100,7 +1098,7 @@ export class HttpClient { */ get(url: string, options: { headers?: HttpHeaders|{[header: string]: string | string[]}, - observe?: HttpObserve, + observe?: 'body'|'events'|'response', params?: HttpParams|{[param: string]: string | string[]}, reportProgress?: boolean, responseType?: 'arraybuffer'|'blob'|'json'|'text', @@ -1382,7 +1380,7 @@ export class HttpClient { */ head(url: string, options: { headers?: HttpHeaders|{[header: string]: string | string[]}, - observe?: HttpObserve, + observe?: 'body'|'events'|'response', params?: HttpParams|{[param: string]: string | string[]}, reportProgress?: boolean, responseType?: 'arraybuffer'|'blob'|'json'|'text', @@ -1711,7 +1709,7 @@ export class HttpClient { */ options(url: string, options: { headers?: HttpHeaders|{[header: string]: string | string[]}, - observe?: HttpObserve, + observe?: 'body'|'events'|'response', params?: HttpParams|{[param: string]: string | string[]}, reportProgress?: boolean, responseType?: 'arraybuffer'|'blob'|'json'|'text', @@ -2005,7 +2003,7 @@ export class HttpClient { */ patch(url: string, body: any|null, options: { headers?: HttpHeaders|{[header: string]: string | string[]}, - observe?: HttpObserve, + observe?: 'body'|'events'|'response', params?: HttpParams|{[param: string]: string | string[]}, reportProgress?: boolean, responseType?: 'arraybuffer'|'blob'|'json'|'text', @@ -2299,7 +2297,7 @@ export class HttpClient { */ post(url: string, body: any|null, options: { headers?: HttpHeaders|{[header: string]: string | string[]}, - observe?: HttpObserve, + observe?: 'body'|'events'|'response', params?: HttpParams|{[param: string]: string | string[]}, reportProgress?: boolean, responseType?: 'arraybuffer'|'blob'|'json'|'text', @@ -2592,7 +2590,7 @@ export class HttpClient { */ put(url: string, body: any|null, options: { headers?: HttpHeaders|{[header: string]: string | string[]}, - observe?: HttpObserve, + observe?: 'body'|'events'|'response', params?: HttpParams|{[param: string]: string | string[]}, reportProgress?: boolean, responseType?: 'arraybuffer'|'blob'|'json'|'text',