Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update router_state.ts #1

Merged
merged 1 commit into from
Feb 22, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions packages/router/src/router_state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export function createEmptyStateSnapshot(rootComponent: Type<any> | null): Route
*
* @publicApi
*/
export class ActivatedRoute {
export class ActivatedRoute<T extends Data = Data> {
/** The current snapshot of this route */
snapshot!: ActivatedRouteSnapshot;
/** @internal */
Expand All @@ -146,7 +146,7 @@ export class ActivatedRoute {
/** An observable of the URL fragment shared by all the routes. */
public fragment: Observable<string | null>;
/** An observable of the static and resolved data of this route. */
public data: Observable<Data>;
public data: Observable<T>;

/** @internal */
constructor(
Expand All @@ -159,15 +159,15 @@ export class ActivatedRoute {
/** @internal */
public fragmentSubject: BehaviorSubject<string | null>,
/** @internal */
public dataSubject: BehaviorSubject<Data>,
public dataSubject: BehaviorSubject<T>,
/** The outlet name of the route, a constant. */
public outlet: string,
/** The component of the route, a constant. */
public component: Type<any> | null,
futureSnapshot: ActivatedRouteSnapshot,
) {
this._futureSnapshot = futureSnapshot;
this.title = this.dataSubject?.pipe(map((d: Data) => d[RouteTitleKey])) ?? of(undefined);
this.title = this.dataSubject?.pipe(map((d: T) => d[RouteTitleKey])) ?? of(undefined);
// TODO(atscott): Verify that these can be changed to `.asObservable()` with TGP.
this.url = urlSubject;
this.params = paramsSubject;
Expand Down Expand Up @@ -318,7 +318,7 @@ export function getInherited(
*
* @publicApi
*/
export class ActivatedRouteSnapshot {
export class ActivatedRouteSnapshot<T extends Data = Data> {
/** The configuration used to match this route **/
public readonly routeConfig: Route | null;
/** @internal */
Expand Down Expand Up @@ -368,7 +368,7 @@ export class ActivatedRouteSnapshot {
/** The URL fragment shared by all the routes */
public fragment: string | null,
/** The static and resolved data of this route */
public data: Data,
public data: T,
/** The outlet name of the route */
public outlet: string,
/** The component of the route */
Expand Down
Loading