feat(common): added typed overloaded for `AsyncPipe.transform()` (#14367)
BREAKING CHANGE: Classes that derive from `AsyncPipe` and override `transform()` might not compile correctly. Use of `async` pipe in templates is unaffected. Mitigation: Update derived classes of `AsyncPipe` that override `transform()` to include the type parameter overloads. Related to #12398 PR Close #14367
This commit is contained in:
parent
6b9aa2ca3d
commit
4da7925ad5
|
@ -82,6 +82,9 @@ export class AsyncPipe implements OnDestroy, PipeTransform {
|
|||
}
|
||||
}
|
||||
|
||||
transform<T>(obj: Observable<T>): T|null;
|
||||
transform<T>(obj: Promise<T>): T|null;
|
||||
transform<T>(obj: EventEmitter<T>): T|null;
|
||||
transform(obj: Observable<any>|Promise<any>|EventEmitter<any>): any {
|
||||
if (!this._obj) {
|
||||
if (obj) {
|
||||
|
@ -93,7 +96,7 @@ export class AsyncPipe implements OnDestroy, PipeTransform {
|
|||
|
||||
if (obj !== this._obj) {
|
||||
this._dispose();
|
||||
return this.transform(obj);
|
||||
return this.transform(obj as any);
|
||||
}
|
||||
|
||||
if (this._latestValue === this._latestReturnedValue) {
|
||||
|
|
|
@ -5,7 +5,9 @@ export declare const APP_BASE_HREF: InjectionToken<string>;
|
|||
export declare class AsyncPipe implements OnDestroy, PipeTransform {
|
||||
constructor(_ref: ChangeDetectorRef);
|
||||
ngOnDestroy(): void;
|
||||
transform(obj: Observable<any> | Promise<any> | EventEmitter<any>): any;
|
||||
transform<T>(obj: EventEmitter<T>): T | null;
|
||||
transform<T>(obj: Promise<T>): T | null;
|
||||
transform<T>(obj: Observable<T>): T | null;
|
||||
}
|
||||
|
||||
/** @stable */
|
||||
|
|
Loading…
Reference in New Issue