import { ActivatedRoute , ActivatedRouteSnapshot , convertToParamMap , Data , Params , Route , UrlSegment } from '@angular/router' ; import { Observable , map } from 'rxjs' ; import { Type } from '@angular/core' ; returns export function fakeRoute ( options ) { const result = { url : options . url , params : options . params , paramMap : options . params && options . params . pipe ( map ( params => convertToParamMap ( params ) ) ) , queryParams : options . queryParams , queryParamMap : options . queryParams && options . queryParams . pipe ( map ( params => convertToParamMap ( params ) ) ) , fragment : options . fragment , data : options . data , outlet : options . outlet , component : options . component , snapshot : options . snapshot , routeConfig : options . routeConfig , root : options . root , parent : options . parent , firstChild : options . firstChild , children : options . children , pathFromRoot : options . pathFromRoot } as ActivatedRoute ; for ( let route = result ; route ; route = route . parent ) { if ( route . parent && route . parent . snapshot && ! route . snapshot ) { route . snapshot = fakeSnapshot ( { } ) ; } if ( route . parent && route . parent . snapshot && ! route . snapshot . parent ) { ( route . snapshot as Omit < ActivatedRouteSnapshot , 'parent' > & { parent : ActivatedRouteSnapshot ; } ) . parent = route . parent . snapshot ; } if ( route . snapshot && route . snapshot . parent && ! route . parent ) { ( route as Omit < ActivatedRoute , 'parent' > & { parent : ActivatedRoute ; } ) . parent = fakeRoute ( { } ) ; } if ( route . snapshot && route . snapshot . parent && route . parent && ! route . parent . snapshot ) { route . parent . snapshot = route . snapshot . parent ; } } return result ; } returns export function fakeSnapshot ( options ) { return { url : options . url , params : options . params , paramMap : options . params && convertToParamMap ( options . params ) , queryParams : options . queryParams , queryParamMap : options . queryParams && convertToParamMap ( options . queryParams ) , fragment : options . fragment , data : options . data , outlet : options . outlet , component : options . component , routeConfig : options . routeConfig , root : options . root , parent : options . parent , firstChild : options . firstChild , children : options . children , pathFromRoot : options . pathFromRoot } as ActivatedRouteSnapshot ; }