Skip to content

fix(router): expose reload method on ActivatedRoute resources - #70702

Merged
thePunderWoman merged 1 commit into
angular:mainfrom
atscott:router-resource-reload
Sep 21, 2026
Merged

thePunderWoman merged 1 commit into
angular:mainfrom
atscott:router-resource-reload

Conversation

@atscott

@atscott atscott commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Resources managed by the Angular Router implement a reload(): boolean method, but ResourceResult typed resources on ActivatedRoute.resources and ActivatedRouteSnapshot.resources as Record<string, Resource<unknown>>. This caused TypeScript errors when attempting to call .reload() without a type assertion.

This commit updates ResourceResult to intersect each resource with Pick<WritableResource<unknown>, 'reload'> so that .reload() is properly typed. Additionally, Route.resources now also accepts Record<string, Resource<unknown>> to allow returning custom or read-only resources without a reload method.

Fixes #70698

@atscott atscott added the target: minor This PR is targeted for the next minor release label Sep 11, 2026
@pullapprove
pullapprove Bot requested a review from alan-agius4 September 11, 2026 19:55
@ngbot ngbot Bot added this to the Backlog milestone Sep 11, 2026
Resources managed by the Angular Router implement a `reload(): boolean` method, but `ResourceResult` typed resources on `ActivatedRoute.resources` and `ActivatedRouteSnapshot.resources` as `Record<string, Resource<unknown>>`. This caused TypeScript errors when attempting to call `.reload()` without a type assertion.

This commit updates `ResourceResult` to intersect each resource with `Pick<WritableResource<unknown>, 'reload'>` so that `.reload()` is properly typed.

Fixes angular#70698
@atscott
atscott force-pushed the router-resource-reload branch from 3a6d609 to dbbffde Compare September 11, 2026 19:57
@atscott
atscott requested a review from JeanMeche September 11, 2026 21:06

@JeanMeche JeanMeche left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, adding reload to Resource is probably an item for the next breaking change window (or should we add intermediate ReloadableResource type ?

@michael-small

Copy link
Copy Markdown
Contributor

I know the above comment about reload+Resource was moreso just between you two, but for my own two cents, I know people who would appreciate non-writables to have a reload. I get that things like resources from snapshots are about the state behavior, but I feel like reloading would be reasonable in that paradigm.

@atscott atscott added action: merge The PR is ready for merge by the caretaker merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note labels Sep 21, 2026
@atscott

atscott commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

caretaker: please do public api review

@JeanMeche JeanMeche left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewed-for: public-api

@thePunderWoman

Copy link
Copy Markdown
Contributor

caretaker: please do public api review

Don't tell me what to do!! LOL

OK fine.

reviewed-for: public-api

@thePunderWoman
thePunderWoman removed the request for review from alan-agius4 September 21, 2026 16:50
@pullapprove
pullapprove Bot requested a review from alan-agius4 September 21, 2026 16:50
@thePunderWoman thePunderWoman removed the merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note label Sep 21, 2026

@alan-agius4 alan-agius4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed-for: dev-infra

@thePunderWoman
thePunderWoman merged commit e048e75 into angular:main Sep 21, 2026
27 checks passed
@thePunderWoman

Copy link
Copy Markdown
Contributor

This PR was merged into the repository. The changes were merged into the following branches:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: router target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug/docs?: router resources and reloading ability is conflicting with types and docs

5 participants