Skip to content

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

Closed

Description

@michael-small

Which @angular/* package(s) are the source of the bug?

router

Is this a regression?

No

Description

The router resource preview docs say that router resources can be reloaded like so:

export class UserProfile {
  user = input.required<User>();
  private userResource = inject(ActivatedRoute).resources?.['user'];

  refreshUser() {
    // Reloads only this specific resource without renavigating the route
    this.userResource?.reload();
  }
}

However, the typing exposed for resources on activated routes (type ResourceResult = Record<string, Resource<unknown>>) works such that you have to cast the resources[string] for activated route access to consumers from Resource to ResourceRef

export class UserProfile
  user = input.required<User>();
  private userResource = inject(ActivatedRoute).resources?.['user'];

  refreshUser() {
    // Reloads only this specific resource without renavigating the route
    (this.userResource as ResourceRef<unknown> | undefined)?.reload();
  }
}

I cannot tell if this is a docs issue or a code type issue. Perhaps it is the later? It seems that internally from what I see in the tests and some of the router resource code, that the inner functionality and test utils are derived from export function routerResource<T>(source: Resource<T>): Resource<T> & {reload(): boolean}. I would assume then that the ActivatedRoute typing for resources would be be type ResourceResult = Record<string, Resource<unknown> & {reload(): boolean}>.

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/stackblitz-starters-wvxzxeg9?file=src%2Fcomponents.ts

Please provide the exception or error you saw

Property 'reload' does not exist on type 'Resource<unknown>'.(2339)

Please provide the environment you discovered this bug in (run ng version)

Angular CLI       : 22.2.0-next.6
Angular           : 22.2.0-next.7
Node.js           : 22.22.3
Package Manager   : npm 10.8.2
Operating System  : linux x64

┌───────────────────────────┬───────────────────┬───────────────────┐
│ Package                   │ Installed Version │ Requested Version │
├───────────────────────────┼───────────────────┼───────────────────┤
│ @angular/build            │ 22.2.0-next.6     │ ^22.2.0-next.6    │
│ @angular/cli              │ 22.2.0-next.6     │ ^22.2.0-next.6    │
│ @angular/common           │ 22.2.0-next.7     │ ^22.2.0-next.7    │
│ @angular/compiler         │ 22.2.0-next.7     │ ^22.2.0-next.7    │
│ @angular/compiler-cli     │ 22.2.0-next.7     │ ^22.2.0-next.7    │
│ @angular/core             │ 22.2.0-next.7     │ ^22.2.0-next.7    │
│ @angular/forms            │ 22.2.0-next.7     │ ^22.2.0-next.7    │
│ @angular/platform-browser │ 22.2.0-next.7     │ ^22.2.0-next.7    │
│ @angular/router           │ 22.2.0-next.7     │ ^22.2.0-next.7    │
│ rxjs                      │ 7.8.2             │ ^7.8.1            │
│ typescript                │ 6.0.3             │ ^6.0.3            │

Anything else?

@atscott I saw you have some active drafts and an open PR for changes going into router resources, but as of writing out this issue, I didn't see a docs change or type change that addressed this.

PS this stuff is really cool, thank you for router resources.

Activity

  1. added this to the needsTriage milestone on Sep 11, 2026
  2. added this to the needsTriage milestone on Sep 11, 2026
  3. atscott commented on Sep 11, 2026

    @atscott
    Contributor

    Thanks for the feedback. I'll see what I can do here. I really wish reload was part of the base Resource interface and not just writable resource...

  4. added 3 commits that reference this issue on Sep 11, 2026
    164a232
    3a6d609
    dbbffde
  5. added a commit that references this issue on Sep 21, 2026
    e048e75
  6. added a commit that references this issue on Sep 22, 2026
    6f5a4a0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: routergemini-triagedLabel noting that an issue has been triaged by gemini

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions