diff --git a/packages/router/src/directives/router_link.ts b/packages/router/src/directives/router_link.ts index 86fb3645e1..c12ca2c8cf 100644 --- a/packages/router/src/directives/router_link.ts +++ b/packages/router/src/directives/router_link.ts @@ -11,7 +11,7 @@ import {Attribute, Directive, ElementRef, HostBinding, HostListener, Input, OnCh import {Subscription} from 'rxjs'; import {QueryParamsHandling} from '../config'; -import {NavigationEnd, RouterEvent} from '../events'; +import {Event, NavigationEnd} from '../events'; import {Router} from '../router'; import {ActivatedRoute} from '../router_state'; import {UrlTree} from '../url_tree'; @@ -220,7 +220,7 @@ export class RouterLinkWithHref implements OnChanges, OnDestroy { constructor( private router: Router, private route: ActivatedRoute, private locationStrategy: LocationStrategy) { - this.subscription = router.events.subscribe((s: RouterEvent) => { + this.subscription = router.events.subscribe((s: Event) => { if (s instanceof NavigationEnd) { this.updateTargetUrlAndHref(); } diff --git a/packages/router/src/directives/router_link_active.ts b/packages/router/src/directives/router_link_active.ts index 1b1338f705..9b7e3af4f4 100644 --- a/packages/router/src/directives/router_link_active.ts +++ b/packages/router/src/directives/router_link_active.ts @@ -9,7 +9,7 @@ import {AfterContentInit, ContentChildren, Directive, ElementRef, Input, OnChanges, OnDestroy, Optional, QueryList, Renderer2, SimpleChanges} from '@angular/core'; import {Subscription} from 'rxjs'; -import {NavigationEnd, RouterEvent} from '../events'; +import {Event, NavigationEnd} from '../events'; import {Router} from '../router'; import {RouterLink, RouterLinkWithHref} from './router_link'; @@ -95,7 +95,7 @@ export class RouterLinkActive implements OnChanges, private router: Router, private element: ElementRef, private renderer: Renderer2, @Optional() private link?: RouterLink, @Optional() private linkWithHref?: RouterLinkWithHref) { - this.subscription = router.events.subscribe((s: RouterEvent) => { + this.subscription = router.events.subscribe((s: Event) => { if (s instanceof NavigationEnd) { this.update(); } diff --git a/packages/router/src/router_module.ts b/packages/router/src/router_module.ts index 27f768b4ec..9a15bcc637 100644 --- a/packages/router/src/router_module.ts +++ b/packages/router/src/router_module.ts @@ -16,7 +16,7 @@ import {Route, Routes} from './config'; import {RouterLink, RouterLinkWithHref} from './directives/router_link'; import {RouterLinkActive} from './directives/router_link_active'; import {RouterOutlet} from './directives/router_outlet'; -import {RouterEvent} from './events'; +import {Event} from './events'; import {RouteReuseStrategy} from './route_reuse_strategy'; import {ErrorHandler, Router} from './router'; import {ROUTES} from './router_config_loader'; @@ -444,7 +444,7 @@ export function setupRouter( if (opts.enableTracing) { const dom = getDOM(); - router.events.subscribe((e: RouterEvent) => { + router.events.subscribe((e: Event) => { dom.logGroup(`Router Event: ${(e.constructor).name}`); dom.log(e.toString()); dom.log(e); diff --git a/packages/router/src/utils/collection.ts b/packages/router/src/utils/collection.ts index b71c5257f7..d6c47dda19 100644 --- a/packages/router/src/utils/collection.ts +++ b/packages/router/src/utils/collection.ts @@ -88,11 +88,14 @@ export function waitForMap( } }); - // Closure compiler has problem with using spread operator here. So just using Array.concat. - return of .apply(null, waitHead.concat(waitTail)).pipe(concatAll(), lastValue(), map(() => res)); + // Closure compiler has problem with using spread operator here. So we use "Array.concat". + // Note that we also need to cast the new promise because TypeScript cannot infer the type + // when calling the "of" function through "Function.apply" + return (of .apply(null, waitHead.concat(waitTail)) as Observable>) + .pipe(concatAll(), lastValue(), map(() => res)); } -export function wrapIntoObservable(value: T | NgModuleFactory| Promise| Observable) { +export function wrapIntoObservable(value: T | Promise| Observable): Observable { if (isObservable(value)) { return value; }