Skip to content

ResourceRef<unknown|undefined>/HttpResourceRef<unknown|undefined> is narrowed to never when using hasValue() #63545

@sysmat

Description

@sysmat

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

core

Is this a regression?

Yes

Description

  1. following documentation: https://angular.dev/guide/http/http-resource
  2. getting compiler error

Please provide a link to a minimal reproduction of the bug

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

Please provide the exception or error you saw

✘ [ERROR] TS2339: Property 'error' does not exist on type 'never'. [plugin angular-compiler]

    src/main.ts:18:21:
      18 │ } @else if (resource.error()) {
         ╵                      ~~~~~


✘ [ERROR] TS2339: Property 'isLoading' does not exist on type 'never'. [plugin angular-compiler]

    src/main.ts:20:21:
      20 │ } @else if (resource.isLoading()) {
         ╵                      ~~~~~~~~~

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

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

Package                      Version
------------------------------------
@angular-devkit/architect    0.2002.1
@angular-devkit/core         20.2.1
@angular-devkit/schematics   20.2.1
@angular/build               20.2.1
@angular/cli                 20.2.1
@schematics/angular          20.2.1
rxjs                         7.8.2
typescript                   5.9.2
zone.js                      0.15.1

Anything else?

control flow @else if not working, but @if it works

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: types

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions