cleanup(router): make strictNullChecks happy

This commit is contained in:
vsavkin
2016-06-02 11:40:47 -07:00
parent d95f0fd83d
commit 1914847e72
6 changed files with 13 additions and 13 deletions

View File

@ -3,7 +3,7 @@ import { TreeNode } from './utils/tree';
import { BehaviorSubject } from 'rxjs/BehaviorSubject'; import { BehaviorSubject } from 'rxjs/BehaviorSubject';
export function createRouterState(curr: RouterStateSnapshot, prevState: RouterState): RouterState { export function createRouterState(curr: RouterStateSnapshot, prevState: RouterState): RouterState {
const root = createNode(curr._root, prevState ? prevState._root : null); const root = createNode(curr._root, prevState ? prevState._root : undefined);
const queryParams = prevState ? prevState.queryParams : new BehaviorSubject(curr.queryParams); const queryParams = prevState ? prevState.queryParams : new BehaviorSubject(curr.queryParams);
const fragment = prevState ? prevState.fragment : new BehaviorSubject(curr.fragment); const fragment = prevState ? prevState.fragment : new BehaviorSubject(curr.fragment);
return new RouterState(root, queryParams, fragment, curr); return new RouterState(root, queryParams, fragment, curr);

View File

@ -174,7 +174,7 @@ class MatchResult {
public leftOverUrl: TreeNode<UrlSegment>[], public leftOverUrl: TreeNode<UrlSegment>[],
public secondary: TreeNode<UrlSegment>[], public secondary: TreeNode<UrlSegment>[],
public outlet: string, public outlet: string,
public route: Route, public route: Route | null,
public lastUrlSegment: UrlSegment public lastUrlSegment: UrlSegment
) {} ) {}
} }

View File

@ -218,15 +218,15 @@ class GuardChecks {
const future = futureNode.value; const future = futureNode.value;
const curr = currNode ? currNode.value : null; const curr = currNode ? currNode.value : null;
if (future === curr) { if (curr && future === curr) {
if (!shallowEqual(future.params, curr.params)) { if (!shallowEqual(future.params, curr.params)) {
this.checks.push(future); this.checks.push(future);
} }
this.traverseChildRoutes(futureNode, currNode, null); this.traverseChildRoutes(futureNode, currNode, <any>null);
} else { } else {
this.deactivateOutletAndItChildren(null); this.deactivateOutletAndItChildren(<any>null);
this.checks.push(future); this.checks.push(future);
this.traverseChildRoutes(futureNode, null, null); this.traverseChildRoutes(futureNode, null, <any>null);
} }
} }

View File

@ -90,7 +90,7 @@ export class ActivatedRouteSnapshot {
_resolvedComponentFactory: ComponentFactory<any>; _resolvedComponentFactory: ComponentFactory<any>;
/** @internal **/ /** @internal **/
_routeConfig: Route; _routeConfig: Route | null;
/** @internal **/ /** @internal **/
_lastUrlSegment: UrlSegment; _lastUrlSegment: UrlSegment;
@ -99,7 +99,7 @@ export class ActivatedRouteSnapshot {
public params: Params, public params: Params,
public outlet: string, public outlet: string,
public component: Type | string, public component: Type | string,
routeConfig: Route, routeConfig: Route | null,
lastUrlSegment: UrlSegment) { lastUrlSegment: UrlSegment) {
this._routeConfig = routeConfig; this._routeConfig = routeConfig;
this._lastUrlSegment = lastUrlSegment; this._lastUrlSegment = lastUrlSegment;
@ -120,7 +120,7 @@ export class ActivatedRouteSnapshot {
* ``` * ```
*/ */
export class RouterStateSnapshot extends Tree<ActivatedRouteSnapshot> { export class RouterStateSnapshot extends Tree<ActivatedRouteSnapshot> {
constructor(root: TreeNode<ActivatedRouteSnapshot>, public queryParams: Params, public fragment: string) { constructor(root: TreeNode<ActivatedRouteSnapshot>, public queryParams: Params, public fragment: string | null) {
super(root); super(root);
} }
} }

View File

@ -174,7 +174,7 @@ function create(start: UrlSegment | null, tree: UrlTree, commands: any[], queryP
if (!start) { if (!start) {
expect(start).toBeDefined(); expect(start).toBeDefined();
} }
const s = new ActivatedRouteSnapshot([], <any>null, PRIMARY_OUTLET, "someComponent", null, start); const s = new ActivatedRouteSnapshot([], <any>null, PRIMARY_OUTLET, "someComponent", null, <any>start);
const a = new ActivatedRoute(<any>null, <any>null, PRIMARY_OUTLET, "someComponent", s); const a = new ActivatedRoute(<any>null, <any>null, PRIMARY_OUTLET, "someComponent", s);
return createUrlTree(a, tree, commands, queryParameters, fragment); return createUrlTree(a, tree, commands, queryParameters, fragment);
} }

View File

@ -202,7 +202,7 @@ describe('recognize', () => {
{ path: 'a', component: ComponentA }, { path: 'a', component: ComponentA },
{ path: 'b', component: ComponentB, outlet: 'aux' }, { path: 'b', component: ComponentB, outlet: 'aux' },
{ path: 'c', component: ComponentC, outlet: 'aux' } { path: 'c', component: ComponentC, outlet: 'aux' }
], tree("a(aux:b//aux:c)")).subscribe(null, s => { ], tree("a(aux:b//aux:c)")).subscribe((_) => {}, s => {
expect(s.toString()).toContain("Two segments cannot have the same outlet name: 'aux:b' and 'aux:c'."); expect(s.toString()).toContain("Two segments cannot have the same outlet name: 'aux:b' and 'aux:c'.");
}); });
}); });
@ -210,7 +210,7 @@ describe('recognize', () => {
it("should error when no matching routes", () => { it("should error when no matching routes", () => {
recognize(RootComponent, [ recognize(RootComponent, [
{ path: 'a', component: ComponentA } { path: 'a', component: ComponentA }
], tree("invalid")).subscribe(null, s => { ], tree("invalid")).subscribe((_) => {}, s => {
expect(s.toString()).toContain("Cannot match any routes"); expect(s.toString()).toContain("Cannot match any routes");
}); });
}); });
@ -218,7 +218,7 @@ describe('recognize', () => {
it("should error when no matching routes (too short)", () => { it("should error when no matching routes (too short)", () => {
recognize(RootComponent, [ recognize(RootComponent, [
{ path: 'a/:id', component: ComponentA } { path: 'a/:id', component: ComponentA }
], tree("a")).subscribe(null, s => { ], tree("a")).subscribe((_) => {}, s => {
expect(s.toString()).toContain("Cannot match any routes"); expect(s.toString()).toContain("Cannot match any routes");
}); });
}); });