diff --git a/packages/router-component-store/src/lib/@ngrx/router-store/minimal_serializer.ts b/packages/router-component-store/src/lib/@ngrx/router-store/minimal_serializer.ts index f39c013..8f10646 100644 --- a/packages/router-component-store/src/lib/@ngrx/router-store/minimal_serializer.ts +++ b/packages/router-component-store/src/lib/@ngrx/router-store/minimal_serializer.ts @@ -28,8 +28,8 @@ import { Data, RouterStateSnapshot, } from '@angular/router'; +import { InternalStrictRouteData } from '../../internal-strict-route-data'; import { InternalStrictRouteParams } from '../../internal-strict-route-params'; -import { StrictRouteData } from '../../strict-route-data'; import { MinimalActivatedRouteSnapshot } from './minimal-activated-route-state-snapshot'; import { MinimalRouterStateSnapshot } from './minimal-router-state-snapshot'; @@ -44,7 +44,7 @@ export class MinimalRouterStateSerializer { }; } - #serializeRouteData(routeData: Data): StrictRouteData { + #serializeRouteData(routeData: Data): InternalStrictRouteData { return Object.fromEntries(Object.entries(routeData)); } @@ -56,7 +56,9 @@ export class MinimalRouterStateSerializer { ); return { params: routeSnapshot.params as InternalStrictRouteParams, - data: this.#serializeRouteData(routeSnapshot.data), + data: this.#serializeRouteData( + routeSnapshot.data + ) as InternalStrictRouteData, url: routeSnapshot.url, outlet: routeSnapshot.outlet, title: routeSnapshot.title, diff --git a/packages/router-component-store/src/lib/global-router-store/global-router-store.ts b/packages/router-component-store/src/lib/global-router-store/global-router-store.ts index a2a0c8f..746dfdc 100644 --- a/packages/router-component-store/src/lib/global-router-store/global-router-store.ts +++ b/packages/router-component-store/src/lib/global-router-store/global-router-store.ts @@ -14,9 +14,9 @@ import { MinimalActivatedRouteSnapshot } from '../@ngrx/router-store/minimal-act import { MinimalRouterStateSnapshot } from '../@ngrx/router-store/minimal-router-state-snapshot'; import { MinimalRouterStateSerializer } from '../@ngrx/router-store/minimal_serializer'; import { filterRouterEvents } from '../filter-router-event.operator'; +import { InternalStrictRouteData } from '../internal-strict-route-data'; import { InternalStrictRouteParams } from '../internal-strict-route-params'; import { RouterStore } from '../router-store'; -import { StrictRouteData } from '../strict-route-data'; interface GlobalRouterState { readonly routerState: MinimalRouterStateSnapshot; @@ -56,7 +56,7 @@ export class GlobalRouterStore this.#rootRoute$, (route) => route.queryParams ); - routeData$: Observable = this.select( + routeData$: Observable = this.select( this.currentRoute$, (route) => route.data ); diff --git a/packages/router-component-store/src/lib/internal-strict-route-data.ts b/packages/router-component-store/src/lib/internal-strict-route-data.ts new file mode 100644 index 0000000..5f7c098 --- /dev/null +++ b/packages/router-component-store/src/lib/internal-strict-route-data.ts @@ -0,0 +1,11 @@ +import { Data } from '@angular/router'; +import { OmitSymbolIndex } from './util-types/omit-symbol-index'; +import { StrictNoAny } from './util-types/strict-no-any'; + +/** + * @remarks We use this type to ensure compatibility with {@link Data}. + * @internal + */ +export type InternalStrictRouteData = Readonly< + StrictNoAny> +>; diff --git a/packages/router-component-store/src/lib/local-router-store/local-router-store.ts b/packages/router-component-store/src/lib/local-router-store/local-router-store.ts index 5b54381..bc8fbbd 100644 --- a/packages/router-component-store/src/lib/local-router-store/local-router-store.ts +++ b/packages/router-component-store/src/lib/local-router-store/local-router-store.ts @@ -17,9 +17,9 @@ import { MinimalActivatedRouteSnapshot } from '../@ngrx/router-store/minimal-act import { MinimalRouterStateSnapshot } from '../@ngrx/router-store/minimal-router-state-snapshot'; import { MinimalRouterStateSerializer } from '../@ngrx/router-store/minimal_serializer'; import { filterRouterEvents } from '../filter-router-event.operator'; +import { InternalStrictRouteData } from '../internal-strict-route-data'; import { InternalStrictRouteParams } from '../internal-strict-route-params'; import { RouterStore } from '../router-store'; -import { StrictRouteData } from '../strict-route-data'; interface LocalRouterState { readonly routerState: MinimalRouterStateSnapshot; @@ -45,7 +45,7 @@ export class LocalRouterStore currentRoute$: Observable = this.#localRoute; fragment$: Observable; queryParams$: Observable; - routeData$: Observable; + routeData$: Observable; routeParams$: Observable; title$: Observable; url$: Observable = this.select( diff --git a/packages/router-component-store/src/lib/strict-route-data.ts b/packages/router-component-store/src/lib/strict-route-data.ts index ebef008..0a1866f 100644 --- a/packages/router-component-store/src/lib/strict-route-data.ts +++ b/packages/router-component-store/src/lib/strict-route-data.ts @@ -1,7 +1,3 @@ -import { Data } from '@angular/router'; -import { OmitSymbolIndex } from './util-types/omit-symbol-index'; -import { StrictNoAny } from './util-types/strict-no-any'; - /** * Serializable route `Data` without its symbol index, in particular without the * `Symbol(RouteTitle)` key as this is an internal value for the Angular @@ -9,4 +5,6 @@ import { StrictNoAny } from './util-types/strict-no-any'; * * Additionally, the `any` member type is converted to `unknown`. */ -export type StrictRouteData = Readonly>>; +export interface StrictRouteData { + readonly [key: string]: unknown; +}