cleanup(router): make strictNullChecks happy
This commit is contained in:
parent
d95f0fd83d
commit
1914847e72
|
@ -3,7 +3,7 @@ import { TreeNode } from './utils/tree';
|
|||
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
|
||||
|
||||
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 fragment = prevState ? prevState.fragment : new BehaviorSubject(curr.fragment);
|
||||
return new RouterState(root, queryParams, fragment, curr);
|
||||
|
|
|
@ -174,7 +174,7 @@ class MatchResult {
|
|||
public leftOverUrl: TreeNode<UrlSegment>[],
|
||||
public secondary: TreeNode<UrlSegment>[],
|
||||
public outlet: string,
|
||||
public route: Route,
|
||||
public route: Route | null,
|
||||
public lastUrlSegment: UrlSegment
|
||||
) {}
|
||||
}
|
|
@ -218,15 +218,15 @@ class GuardChecks {
|
|||
const future = futureNode.value;
|
||||
const curr = currNode ? currNode.value : null;
|
||||
|
||||
if (future === curr) {
|
||||
if (curr && future === curr) {
|
||||
if (!shallowEqual(future.params, curr.params)) {
|
||||
this.checks.push(future);
|
||||
}
|
||||
this.traverseChildRoutes(futureNode, currNode, null);
|
||||
this.traverseChildRoutes(futureNode, currNode, <any>null);
|
||||
} else {
|
||||
this.deactivateOutletAndItChildren(null);
|
||||
this.deactivateOutletAndItChildren(<any>null);
|
||||
this.checks.push(future);
|
||||
this.traverseChildRoutes(futureNode, null, null);
|
||||
this.traverseChildRoutes(futureNode, null, <any>null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ export class ActivatedRouteSnapshot {
|
|||
_resolvedComponentFactory: ComponentFactory<any>;
|
||||
|
||||
/** @internal **/
|
||||
_routeConfig: Route;
|
||||
_routeConfig: Route | null;
|
||||
|
||||
/** @internal **/
|
||||
_lastUrlSegment: UrlSegment;
|
||||
|
@ -99,7 +99,7 @@ export class ActivatedRouteSnapshot {
|
|||
public params: Params,
|
||||
public outlet: string,
|
||||
public component: Type | string,
|
||||
routeConfig: Route,
|
||||
routeConfig: Route | null,
|
||||
lastUrlSegment: UrlSegment) {
|
||||
this._routeConfig = routeConfig;
|
||||
this._lastUrlSegment = lastUrlSegment;
|
||||
|
@ -120,7 +120,7 @@ export class 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);
|
||||
}
|
||||
}
|
|
@ -174,7 +174,7 @@ function create(start: UrlSegment | null, tree: UrlTree, commands: any[], queryP
|
|||
if (!start) {
|
||||
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);
|
||||
return createUrlTree(a, tree, commands, queryParameters, fragment);
|
||||
}
|
|
@ -202,7 +202,7 @@ describe('recognize', () => {
|
|||
{ path: 'a', component: ComponentA },
|
||||
{ path: 'b', component: ComponentB, 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'.");
|
||||
});
|
||||
});
|
||||
|
@ -210,7 +210,7 @@ describe('recognize', () => {
|
|||
it("should error when no matching routes", () => {
|
||||
recognize(RootComponent, [
|
||||
{ path: 'a', component: ComponentA }
|
||||
], tree("invalid")).subscribe(null, s => {
|
||||
], tree("invalid")).subscribe((_) => {}, s => {
|
||||
expect(s.toString()).toContain("Cannot match any routes");
|
||||
});
|
||||
});
|
||||
|
@ -218,7 +218,7 @@ describe('recognize', () => {
|
|||
it("should error when no matching routes (too short)", () => {
|
||||
recognize(RootComponent, [
|
||||
{ path: 'a/:id', component: ComponentA }
|
||||
], tree("a")).subscribe(null, s => {
|
||||
], tree("a")).subscribe((_) => {}, s => {
|
||||
expect(s.toString()).toContain("Cannot match any routes");
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue