Skip to content

Commit 22b9f36

Browse files
committed
feat!: use immutable route data
**BREAKING CHANGES** `StrictRouteData` members are now read-only. TypeScript will fail to compile application code that mutates route data data structures. BEFORE: ```typescript // heroes.component.ts // (...) import { RouterStore } from "@ngworker/router-component-store"; @component({ // (...) }) export class DashboardComponent { #routerStore = inject(RouterStore); limit$: Observable<number> = this.#routerStore. routeData$.pipe( map((data) => { data["limit"] = Number(data["limit"]) return data; }), map(data => data["limit"]) ); } ``` AFTER: ```typescript // heroes.component.ts // (...) import { RouterStore } from "@ngworker/router-component-store"; @component({ // (...) }) export class DashboardComponent { #routerStore = inject(RouterStore); limit$: Observable<number> = this.#routerStore.routeData$.pipe( map((data) => Number(data["limit"])) ); } ```
1 parent 70a2c0f commit 22b9f36

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ The `StrictRouteData` interface is used for the `MinimalActivatedRouteSnapshot#d
187187

188188
```typescript
189189
export type StrictRouteData = {
190-
[key: string]: unknown;
190+
readonly [key: string]: unknown;
191191
};
192192
```
193193

packages/router-component-store/src/lib/strict-route-data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ import { StrictNoAny } from './util-types/strict-no-any';
99
*
1010
* Additionally, the `any` member type is converted to `unknown`.
1111
*/
12-
export type StrictRouteData = StrictNoAny<OmitSymbolIndex<Data>>;
12+
export type StrictRouteData = Readonly<StrictNoAny<OmitSymbolIndex<Data>>>;

0 commit comments

Comments
 (0)