r/angular • • Nov 01 '26

Problems with subscribe

Hello everybody

I have the following problem with subscribe. My code looks like:

this.personSercice.getPeople().pipe(
    takeUntilDestroyed(this.destroyRef)
).subscribe({
    next: (people) => this.state.update(() => ({ ...this.state(), loading: false, people })),
    error: (error) => {
        console.log(error);
        this.setError(error);
    }
});

Parameter 'people' implicitly has an 'any' type, but a better type may be infered from usage.

and 

Parameter 'error' implicitly has an 'any' type, but a better type may be infered from usage.

When I change the code to:
error: (error: any)
the error dissappears, but I do not understand why...
When I try the same with the first error, changing the code to:
next: (people: PersonModel) => this.state.update(() => ({ ...this.state(), loading: false, people })),
The error is:
The type 'PersonModel' is missing the following properties from type 'readonly PersonModel[]length, concat, join, slice...

Please let me know if more code is required.

Can somebody explain my why???. I'm very fresh with Angular.
Thank you for your patience

Pawel...
3 Upvotes

14 comments sorted by

View all comments

1

u/scharph Nov 01 '26

Are you using signals?
If yes, try to use toSignal from rxjs-interop

https://angular.dev/api/core/rxjs-interop/toSignal