From 7dfa446c4ace99f4b64069cf672dcaa3665a1f5b Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Wed, 31 Mar 2021 11:09:35 +0100 Subject: [PATCH] fix(common): temporarily re-export and deprecate `XhrFactory` (#41393) The moved `XhrFactory` still needs to be available from `@angular/common/http` for some libraries that were built prior to 12.0.0, otherwise they cannot be used in applications built post-12.0.0. This commit adds back the re-export of `XhrFactory` and deprecates it. PR Close #41393 --- aio/content/guide/deprecations.md | 9 +++++++++ goldens/public-api/common/http/http.d.ts | 5 ++++- packages/common/http/public_api.ts | 21 +++++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/aio/content/guide/deprecations.md b/aio/content/guide/deprecations.md index 38bc81e165..d76d0c099d 100644 --- a/aio/content/guide/deprecations.md +++ b/aio/content/guide/deprecations.md @@ -40,6 +40,7 @@ v12 - v15 | ----------------------------- | --------------------------------------------------------------------------- | ----------------- | | `@angular/common` | [`ReflectiveInjector`](#reflectiveinjector) | v11 | | `@angular/common` | [`CurrencyPipe` - `DEFAULT_CURRENCY_CODE`](api/common/CurrencyPipe#currency-code-deprecation) | v11 | +| `@angular/common/http` | [`XhrFactory`](api/common/http/XhrFactory) | v15 | | `@angular/core` | [`DefaultIterableDiffer`](#core) | v11 | | `@angular/core` | [`ReflectiveKey`](#core) | v11 | | `@angular/core` | [`RenderComponentType`](#core) | v11 | @@ -82,6 +83,14 @@ Tip: In the [API reference section](api) of this doc site, deprecated APIs are i | [`CurrencyPipe` - `DEFAULT_CURRENCY_CODE`](api/common/CurrencyPipe#currency-code-deprecation) | `{provide: DEFAULT_CURRENCY_CODE, useValue: 'USD'}` | v9 | From v11 the default code will be extracted from the locale data given by `LOCAL_ID`, rather than `USD`. | +{@a common-http} +### @angular/common/http + +| API | Replacement | Deprecation announced | Notes | +| -------------------------------------------- | ------------------------------------ | --------------------- | ----- | +| [`XhrFactory`](api/common/http/XhrFactory) | `XhrFactory` in `@angular/common` | v12 | The `XhrFactory` has moved from `@angular/common/http` to `@angular/common`. | + + {@a core} ### @angular/core diff --git a/goldens/public-api/common/http/http.d.ts b/goldens/public-api/common/http/http.d.ts index 91cba7df51..e32d85bd3d 100644 --- a/goldens/public-api/common/http/http.d.ts +++ b/goldens/public-api/common/http/http.d.ts @@ -1930,7 +1930,7 @@ export declare interface HttpUserEvent { } export declare class HttpXhrBackend implements HttpBackend { - constructor(xhrFactory: XhrFactory); + constructor(xhrFactory: XhrFactory_2); handle(req: HttpRequest): Observable>; } @@ -1947,3 +1947,6 @@ export declare class JsonpInterceptor { constructor(jsonp: JsonpClientBackend); intercept(req: HttpRequest, next: HttpHandler): Observable>; } + +/** @deprecated */ +export declare type XhrFactory = XhrFactory_2; diff --git a/packages/common/http/public_api.ts b/packages/common/http/public_api.ts index 12199e8bc4..c08bef4d0c 100644 --- a/packages/common/http/public_api.ts +++ b/packages/common/http/public_api.ts @@ -6,6 +6,27 @@ * found in the LICENSE file at https://angular.io/license */ +import {XhrFactory as XhrFactory_fromAngularCommon} from '@angular/common'; + +/** + * A wrapper around the `XMLHttpRequest` constructor. + * + * @publicApi + * @see `XhrFactory` + * @deprecated + * `XhrFactory` has moved, please import `XhrFactory` from `@angular/common` instead. + */ +export type XhrFactory = XhrFactory_fromAngularCommon; +/** + * A wrapper around the `XMLHttpRequest` constructor. + * + * @publicApi + * @see `XhrFactory` + * @deprecated + * `XhrFactory` has moved, please import `XhrFactory` from `@angular/common` instead. + */ +export const XhrFactory = XhrFactory_fromAngularCommon; + export {HttpBackend, HttpHandler} from './src/backend'; export {HttpClient} from './src/client'; export {HttpContext, HttpContextToken} from './src/context';