Skip to content

Property error in class HttpErrorResponse should be unknown #50814

@BartoszPiwek

Description

@BartoszPiwek

Which @angular/* package(s) are relevant/related to the feature request?

common/http
(

export class HttpErrorResponse extends HttpResponseBase implements Error {
)

Description

There is a potential issue where the program tries to access properties of null without proper type inference
Programmer should infer type for this:

        error: (res: HttpErrorResponse) => {
         // check if res extends ApiErrorResponse interface
          if (this.apiValidator.isApiErrorResponse(res)) {
            this.onError(res.error.errorCode);
          }
        },

Proposed solution

Change

readonly error: any | null;

to

readonly error: undefined;

Alternatives considered

No alternatives

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: common/httpIssues related to HTTP and HTTP Clientbreaking changesfeatureIssue that requests a new featurefeature: insufficient votesLabel to add when the not a sufficient number of votes or comments from unique authors

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions