diff --git a/goldens/public-api/common/common.d.ts b/goldens/public-api/common/common.d.ts index 4d3601fd08786..939f137fdc713 100644 --- a/goldens/public-api/common/common.d.ts +++ b/goldens/public-api/common/common.d.ts @@ -3,9 +3,9 @@ export declare const APP_BASE_HREF: InjectionToken; export declare class AsyncPipe implements OnDestroy, PipeTransform { constructor(_ref: ChangeDetectorRef); ngOnDestroy(): void; - transform(obj: Subscribable | Promise): T | null; + transform(obj: Observable | Subscribable | Promise): T | null; transform(obj: null | undefined): null; - transform(obj: Subscribable | Promise | null | undefined): T | null; + transform(obj: Observable | Subscribable | Promise | null | undefined): T | null; } export declare class CommonModule { diff --git a/packages/common/src/pipes/async_pipe.ts b/packages/common/src/pipes/async_pipe.ts index 6365dbc067540..9bb43b8862a3b 100644 --- a/packages/common/src/pipes/async_pipe.ts +++ b/packages/common/src/pipes/async_pipe.ts @@ -7,7 +7,7 @@ */ import {ChangeDetectorRef, EventEmitter, OnDestroy, Pipe, PipeTransform, ɵisPromise, ɵisSubscribable} from '@angular/core'; -import {Subscribable, Unsubscribable} from 'rxjs'; +import {Observable, Subscribable, Unsubscribable} from 'rxjs'; import {invalidPipeArgumentError} from './invalid_pipe_argument_error'; @@ -95,10 +95,14 @@ export class AsyncPipe implements OnDestroy, PipeTransform { } } - transform(obj: Subscribable|Promise): T|null; + // NOTE(@benlesh): Because Observable has deprecated a few call patterns for `subscribe`, + // TypeScript has a hard time matching Observable to Subscribable, for more information + // see https://github.com/microsoft/TypeScript/issues/43643 + + transform(obj: Observable|Subscribable|Promise): T|null; transform(obj: null|undefined): null; - transform(obj: Subscribable|Promise|null|undefined): T|null; - transform(obj: Subscribable|Promise|null|undefined): T|null { + transform(obj: Observable|Subscribable|Promise|null|undefined): T|null; + transform(obj: Observable|Subscribable|Promise|null|undefined): T|null { if (!this._obj) { if (obj) { this._subscribe(obj);