Skip to content

rxResource params field type in stream function doesn't derive possible null value #62724

@artaommahe

Description

@artaommahe

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

core

Is this a regression?

Yes

Description

There is a specific case when (() => Smth) | undefined is passed to rxResource.params field that ends with a wrong type of rxResource.stream.params field - possible null value is not mentioned in the type.

code (or check the reproduction link)

params = signal<Params | undefined>(undefined);
data = rxResource({
  params: this.getParams(),
  stream: ({ params }) => {
    console.log('> params', params);
    return NEVER;
  },
});

getParams(): Params | undefined {
  if (!this.params()) {
    return undefined;
  }

  return () => this.params();
}

params type inside stream function is (parameter) params: Params but in reality its value can be null if getParams() returns undefined

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/kuh9jtu5?file=src%2Fmain.ts

Please provide the exception or error you saw


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

Angular CLI: 20.1.1
Node: 24.1.0
Package Manager: npm 11.3.0
OS: darwin arm64

Angular: 20.1.2
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.2001.1
@angular-devkit/core         20.1.1
@angular-devkit/schematics   20.1.1
@angular/build               20.1.1
@angular/cli                 20.1.1
@schematics/angular          20.1.1
rxjs                         7.8.2
typescript                   5.8.3

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: coreIssues related to the framework runtimecore: reactivityWork related to fine-grained reactivity in the core frameworkcross-cutting: resourceIssues related to the newly introduced resource / httpResource

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions