fix(router): Update types for TypeScript nullability support
This reverts commit ea8ffc9841
.
This commit is contained in:

committed by
Tobias Bosch

parent
ec028b8109
commit
bc431888f3
@ -57,7 +57,7 @@ export class RouterState extends Tree<ActivatedRoute> {
|
||||
toString(): string { return this.snapshot.toString(); }
|
||||
}
|
||||
|
||||
export function createEmptyState(urlTree: UrlTree, rootComponent: Type<any>): RouterState {
|
||||
export function createEmptyState(urlTree: UrlTree, rootComponent: Type<any>| null): RouterState {
|
||||
const snapshot = createEmptyStateSnapshot(urlTree, rootComponent);
|
||||
const emptyUrl = new BehaviorSubject([new UrlSegment('', {})]);
|
||||
const emptyParams = new BehaviorSubject({});
|
||||
@ -72,7 +72,7 @@ export function createEmptyState(urlTree: UrlTree, rootComponent: Type<any>): Ro
|
||||
}
|
||||
|
||||
export function createEmptyStateSnapshot(
|
||||
urlTree: UrlTree, rootComponent: Type<any>): RouterStateSnapshot {
|
||||
urlTree: UrlTree, rootComponent: Type<any>| null): RouterStateSnapshot {
|
||||
const emptyParams = {};
|
||||
const emptyData = {};
|
||||
const emptyQueryParams = {};
|
||||
@ -132,21 +132,21 @@ export class ActivatedRoute {
|
||||
public outlet: string,
|
||||
/** The component of the route. It's a constant */
|
||||
// TODO(vsavkin): remove |string
|
||||
public component: Type<any>|string, futureSnapshot: ActivatedRouteSnapshot) {
|
||||
public component: Type<any>|string|null, futureSnapshot: ActivatedRouteSnapshot) {
|
||||
this._futureSnapshot = futureSnapshot;
|
||||
}
|
||||
|
||||
/** The configuration used to match this route */
|
||||
get routeConfig(): Route { return this._futureSnapshot.routeConfig; }
|
||||
get routeConfig(): Route|null { return this._futureSnapshot.routeConfig; }
|
||||
|
||||
/** The root of the router state */
|
||||
get root(): ActivatedRoute { return this._routerState.root; }
|
||||
|
||||
/** The parent of this route in the router state tree */
|
||||
get parent(): ActivatedRoute { return this._routerState.parent(this); }
|
||||
get parent(): ActivatedRoute|null { return this._routerState.parent(this); }
|
||||
|
||||
/** The first child of this route in the router state tree */
|
||||
get firstChild(): ActivatedRoute { return this._routerState.firstChild(this); }
|
||||
get firstChild(): ActivatedRoute|null { return this._routerState.firstChild(this); }
|
||||
|
||||
/** The children of this route in the router state tree */
|
||||
get children(): ActivatedRoute[] { return this._routerState.children(this); }
|
||||
@ -234,7 +234,7 @@ export function inheritedParamsDataResolve(route: ActivatedRouteSnapshot): Inher
|
||||
*/
|
||||
export class ActivatedRouteSnapshot {
|
||||
/** @internal **/
|
||||
_routeConfig: Route;
|
||||
_routeConfig: Route|null;
|
||||
/** @internal **/
|
||||
_urlSegment: UrlSegmentGroup;
|
||||
/** @internal */
|
||||
@ -265,7 +265,7 @@ export class ActivatedRouteSnapshot {
|
||||
/** The outlet name of the route */
|
||||
public outlet: string,
|
||||
/** The component of the route */
|
||||
public component: Type<any>|string, routeConfig: Route, urlSegment: UrlSegmentGroup,
|
||||
public component: Type<any>|string|null, routeConfig: Route|null, urlSegment: UrlSegmentGroup,
|
||||
lastPathIndex: number, resolve: ResolveData) {
|
||||
this._routeConfig = routeConfig;
|
||||
this._urlSegment = urlSegment;
|
||||
@ -274,16 +274,16 @@ export class ActivatedRouteSnapshot {
|
||||
}
|
||||
|
||||
/** The configuration used to match this route */
|
||||
get routeConfig(): Route { return this._routeConfig; }
|
||||
get routeConfig(): Route|null { return this._routeConfig; }
|
||||
|
||||
/** The root of the router state */
|
||||
get root(): ActivatedRouteSnapshot { return this._routerState.root; }
|
||||
|
||||
/** The parent of this route in the router state tree */
|
||||
get parent(): ActivatedRouteSnapshot { return this._routerState.parent(this); }
|
||||
get parent(): ActivatedRouteSnapshot|null { return this._routerState.parent(this); }
|
||||
|
||||
/** The first child of this route in the router state tree */
|
||||
get firstChild(): ActivatedRouteSnapshot { return this._routerState.firstChild(this); }
|
||||
get firstChild(): ActivatedRouteSnapshot|null { return this._routerState.firstChild(this); }
|
||||
|
||||
/** The children of this route in the router state tree */
|
||||
get children(): ActivatedRouteSnapshot[] { return this._routerState.children(this); }
|
||||
@ -398,5 +398,5 @@ export function equalParamsAndUrlSegments(
|
||||
const parentsMismatch = !a.parent !== !b.parent;
|
||||
|
||||
return equalUrlParams && !parentsMismatch &&
|
||||
(!a.parent || equalParamsAndUrlSegments(a.parent, b.parent));
|
||||
}
|
||||
(!a.parent || equalParamsAndUrlSegments(a.parent, b.parent !));
|
||||
}
|
Reference in New Issue
Block a user