fix: build and test fixes for TS 2.1 (#13294)

This commit is contained in:
Alex Eagle
2017-01-24 09:05:34 -08:00
committed by Miško Hevery
parent 5c431cee02
commit ef32e6b0d0
21 changed files with 66 additions and 39 deletions

View File

@ -20,7 +20,7 @@ import {EmptyError} from 'rxjs/util/EmptyError';
import {Route, Routes} from './config';
import {LoadedRouterConfig, RouterConfigLoader} from './router_config_loader';
import {NavigationCancelingError, PRIMARY_OUTLET, Params, defaultUrlMatcher} from './shared';
import {PRIMARY_OUTLET, Params, defaultUrlMatcher, navigationCancelingError} from './shared';
import {UrlSegment, UrlSegmentGroup, UrlSerializer, UrlTree} from './url_tree';
import {andObservables, forEach, merge, waitForMap, wrapIntoObservable} from './utils/collection';
@ -50,7 +50,7 @@ function namedOutletsRedirect(redirectTo: string): Observable<any> {
function canLoadFails(route: Route): Observable<LoadedRouterConfig> {
return new Observable<LoadedRouterConfig>(
(obs: Observer<LoadedRouterConfig>) => obs.error(new NavigationCancelingError(
(obs: Observer<LoadedRouterConfig>) => obs.error(navigationCancelingError(
`Cannot load children because the guard of the route "path: '${route.path}'" returned false`)));
}

View File

@ -31,7 +31,7 @@ import {DetachedRouteHandle, DetachedRouteHandleInternal, RouteReuseStrategy} fr
import {LoadedRouterConfig, RouterConfigLoader} from './router_config_loader';
import {RouterOutletMap} from './router_outlet_map';
import {ActivatedRoute, ActivatedRouteSnapshot, RouterState, RouterStateSnapshot, advanceActivatedRoute, createEmptyState, equalParamsAndUrlSegments, inheritedParamsDataResolve} from './router_state';
import {NavigationCancelingError, PRIMARY_OUTLET, Params} from './shared';
import {PRIMARY_OUTLET, Params, isNavigationCancelingError} from './shared';
import {DefaultUrlHandlingStrategy, UrlHandlingStrategy} from './url_handling_strategy';
import {UrlSerializer, UrlTree, containsTree, createEmptyUrlTree} from './url_tree';
import {andObservables, forEach, merge, waitForMap, wrapIntoObservable} from './utils/collection';
@ -802,7 +802,7 @@ export class Router {
}
},
(e: any) => {
if (e instanceof NavigationCancelingError) {
if (isNavigationCancelingError(e)) {
this.resetUrlToCurrentUrlTree();
this.navigated = true;
this.routerEvents.next(

View File

@ -27,13 +27,16 @@ export type Params = {
[key: string]: any
};
export class NavigationCancelingError extends Error {
public stack: any;
constructor(public message: string) {
super(message);
this.stack = (<any>new Error(message)).stack;
}
toString(): string { return this.message; }
const NAVIGATION_CANCELING_ERROR = 'ngNavigationCancelingError';
export function navigationCancelingError(message: string) {
const error = Error('NavigationCancelingError: ' + message);
(error as any)[NAVIGATION_CANCELING_ERROR] = true;
return error;
}
export function isNavigationCancelingError(error: Error) {
return (error as any)[NAVIGATION_CANCELING_ERROR];
}
export function defaultUrlMatcher(